ok
Build-Deploy-Actions
Details
Build-Deploy-Actions
Details
This commit is contained in:
commit
9f9bd98743
|
@ -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
|
|
@ -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 }}."
|
||||||
|
|
|
@ -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"]
|
|
@ -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 = " <a href='https://huggingface.co/nateraw/vit-age-classifier'>ViT Age Classification Model Repo on Hugging Face Model Hub</a>"
|
||||||
|
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)
|
Binary file not shown.
After Width: | Height: | Size: 95 KiB |
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
transformers
|
||||||
|
gradio
|
||||||
|
Pillow
|
||||||
|
torch
|
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 157 KiB |
Loading…
Reference in New Issue