From a31fb64f539453f462088aa15088bf99dbda580c Mon Sep 17 00:00:00 2001 From: SOULOFCINDER <841135647@qq.com> Date: Fri, 31 Mar 2023 14:53:31 +0800 Subject: [PATCH] update --- beit_base_patch16_224_pt22k_ft22k/Dockerfile | 25 +++++++++++++++ beit_base_patch16_224_pt22k_ft22k/app.py | 32 ++----------------- .../requirements.txt | 2 ++ 3 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 beit_base_patch16_224_pt22k_ft22k/Dockerfile create mode 100644 beit_base_patch16_224_pt22k_ft22k/requirements.txt diff --git a/beit_base_patch16_224_pt22k_ft22k/Dockerfile b/beit_base_patch16_224_pt22k_ft22k/Dockerfile new file mode 100644 index 0000000..d525920 --- /dev/null +++ b/beit_base_patch16_224_pt22k_ft22k/Dockerfile @@ -0,0 +1,25 @@ +# please visit https://github.com/xfyun/aiges/releases to get stable and suitable iamges. + +FROM docker.io/library/python:3.8.9 + + +RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list +RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list + + +WORKDIR /home/user/app +RUN useradd -m -u 1000 user +RUN chown -R 1000.1000 /home/user + + +RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ + + +RUN pip install --no-cache-dir pip==22.3.1 +RUN --mount=target=requirements.txt,source=requirements.txt pip install --no-cache-dir -r requirements.txt + + +COPY --chown=1000 ./ /home/user/app + + +CMD ["python3", "app.py"] \ No newline at end of file diff --git a/beit_base_patch16_224_pt22k_ft22k/app.py b/beit_base_patch16_224_pt22k_ft22k/app.py index 4a04b62..0e1db1c 100644 --- a/beit_base_patch16_224_pt22k_ft22k/app.py +++ b/beit_base_patch16_224_pt22k_ft22k/app.py @@ -1,5 +1,4 @@ import gradio as gr -from PIL import Image from transformers import BeitImageProcessor, BeitForImageClassification @@ -18,10 +17,11 @@ def inference(img): return model.config.id2label[predicted_class_idx] + title = "Image classification:beit-base-patch16-224-pt22k-ft22k" description = "Gradio Demo for beit-base-patch16-224-pt22k-ft22k. To use it, simply upload your image, or click one of the examples to load them." article = "

Github Repo Pytorch

visitor badge

" -examples=[['example_cat.jpg'],['Masahiro.png']] +examples = [['example_cat.jpg'], ['Masahiro.png']] demo = gr.Interface( fn=inference, @@ -34,31 +34,3 @@ demo = gr.Interface( demo.launch() - -## - - -# model_dir = "hub/animegan2-pytorch-main" -# model_dir_weight = "hub/checkpoints/face_paint_512_v1.pt" -# -# model2 = torch.hub.load( -# model_dir, -# "generator", -# pretrained=True, -# progress=False, -# source="local" -# ) -# model1 = torch.load(model_dir_weight) -# face2paint = torch.hub.load( -# model_dir, 'face2paint', -# size=512,side_by_side=False, -# source="local" -# ) -# -# def inference(img, ver): -# if ver == 'version 2 (🔺 robustness,🔻 stylization)': -# out = face2paint(model2, img) -# else: -# out = face2paint(model1, img) -# return out -# diff --git a/beit_base_patch16_224_pt22k_ft22k/requirements.txt b/beit_base_patch16_224_pt22k_ft22k/requirements.txt new file mode 100644 index 0000000..973b15c --- /dev/null +++ b/beit_base_patch16_224_pt22k_ft22k/requirements.txt @@ -0,0 +1,2 @@ +gradio==3.21.0 +transformers==4.27.1