commit 9f9bd98743e87c61a3d2e995b30b43bdf31fa8c9 Author: jianjiang Date: Fri Apr 21 13:48:37 2023 +0800 ok diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..957b257 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,27 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bin.* filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zstandard filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..1ed1ca9 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,48 @@ +name: Build +run-name: ${{ github.actor }} is upgrade release 🚀 +on: [push] +env: + REPOSITORY: ${{ github.repository }} + COMMIT_ID: ${{ github.sha }} +jobs: + Build-Deploy-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - + name: Setup Git LFS + run: | + git lfs install + git lfs fetch + git lfs checkout + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - + name: Docker Image Info + id: image-info + run: | + echo "::set-output name=image_name::$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]')" + echo "::set-output name=image_tag::${COMMIT_ID:0:10}" + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + registry: artifacts.iflytek.com + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Build and push + run: | + docker version + docker buildx build -t artifacts.iflytek.com/docker-private/atp/${{ steps.image-info.outputs.image_name }}:${{ steps.image-info.outputs.image_tag }} . --file ${{ github.workspace }}/Dockerfile --load + docker push artifacts.iflytek.com/docker-private/atp/${{ steps.image-info.outputs.image_name }}:${{ steps.image-info.outputs.image_tag }} + docker rmi artifacts.iflytek.com/docker-private/atp/${{ steps.image-info.outputs.image_name }}:${{ steps.image-info.outputs.image_tag }} + - run: echo "🍏 This job's status is ${{ job.status }}." + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..671699b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.8.13 + +WORKDIR /app + +COPY . /app + +RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple +RUN pip install -r requirements.txt + +CMD ["python", "app.py"] diff --git a/app.py b/app.py new file mode 100644 index 0000000..5885786 --- /dev/null +++ b/app.py @@ -0,0 +1,47 @@ +from PIL import Image +import gradio as gr +from transformers import ViTFeatureExtractor, ViTForImageClassification +import torch + +# Init model, transforms +model = ViTForImageClassification.from_pretrained('nateraw/vit-age-classifier') +transforms = ViTFeatureExtractor.from_pretrained('nateraw/vit-age-classifier') + +def predict(im): + labels = {0:"0-2", 1: "3-9" , 2: "10-19", 3: "20-29", 4: "30-39", 5: "40-49", 6: "50-59", 7:"60-69",8:"more than 70"} +# Transform our image and pass it through the model + inputs = transforms(im, return_tensors='pt') + output = model(**inputs) + +# Predicted Class probabilities + proba = output.logits.softmax(1) + +# Predicted Classes + preds = proba.argmax(1) + values, indices = torch.topk(proba, k=5) + + + + return {labels[i.item()]: v.item() for i, v in zip(indices.numpy()[0], values.detach().numpy()[0])} + +inputs = [ + gr.inputs.Image(type="pil", label="Input Image") +] + + + +title = "ViT-Age-Classification" +description = "ViT-Age-Classification is used to categorize an individual's age using images" +article = " ViT Age Classification Model Repo on Hugging Face Model Hub" +examples = ["stock_baby.webp","stock_teen.webp","stock_guy.jpg","stock_old_woman.jpg"] + +gr.Interface( + predict, + inputs, + outputs = 'label', + title=title, + description=description, + article=article, + examples=examples, + theme="huggingface", +).launch(debug=True, enable_queue=True) \ No newline at end of file diff --git a/baby.jpg b/baby.jpg new file mode 100644 index 0000000..890659c Binary files /dev/null and b/baby.jpg differ diff --git a/gob remm.png b/gob remm.png new file mode 100644 index 0000000..a2b4091 Binary files /dev/null and b/gob remm.png differ diff --git a/gradio_queue.db b/gradio_queue.db new file mode 100644 index 0000000..229b08a Binary files /dev/null and b/gradio_queue.db differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7d7baa5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +transformers +gradio +Pillow +torch \ No newline at end of file diff --git a/stock_baby.webp b/stock_baby.webp new file mode 100644 index 0000000..d103163 Binary files /dev/null and b/stock_baby.webp differ diff --git a/stock_guy.jpg b/stock_guy.jpg new file mode 100644 index 0000000..54bef08 Binary files /dev/null and b/stock_guy.jpg differ diff --git a/stock_old_woman.jpg b/stock_old_woman.jpg new file mode 100644 index 0000000..6907d93 Binary files /dev/null and b/stock_old_woman.jpg differ diff --git a/stock_teen.webp b/stock_teen.webp new file mode 100644 index 0000000..9e4a166 Binary files /dev/null and b/stock_teen.webp differ diff --git a/surprisa.jpg b/surprisa.jpg new file mode 100644 index 0000000..262ed47 Binary files /dev/null and b/surprisa.jpg differ