Spaces:
Sleeping
Sleeping
mostafasmart
commited on
Commit
·
c0c0506
1
Parent(s):
1080957
mostafa add notifction API
Browse files- app.py +38 -0
- requirements.txt +8 -0
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
from transformers import AutoFeatureExtractor,AutoModelForImageClassification,pipeline
|
6 |
+
|
7 |
+
model_id = "smartgmin/Entrnal_5class_agumm_last_newV7_model"
|
8 |
+
|
9 |
+
|
10 |
+
model2 = AutoModelForImageClassification.from_pretrained(model_id, from_tf=True)
|
11 |
+
|
12 |
+
|
13 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
14 |
+
|
15 |
+
|
16 |
+
clsss = pipeline('image-classification',model=model2,feature_extractor=feature_extractor)
|
17 |
+
|
18 |
+
def predict(image):
|
19 |
+
yl = clsss(image)
|
20 |
+
max_item = max(yl, key=lambda x: x['score'])
|
21 |
+
nn = "{:f}".format(max_item['score'])
|
22 |
+
dd = max_item['label']
|
23 |
+
nn,dd
|
24 |
+
return f"dissesse: {dd} , score : {nn}"
|
25 |
+
|
26 |
+
|
27 |
+
iface = gr.Interface(
|
28 |
+
fn=predict,
|
29 |
+
inputs=gr.inputs.Image(type="pil", label="ارفع صورتك"),
|
30 |
+
outputs="text",
|
31 |
+
title="نموذج ViT لتصنيف الصور",
|
32 |
+
description="قم برفع صورة للحصول على تصنيف باستخدام نموذج ViT المدرب."
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
iface.launch()
|
37 |
+
|
38 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
PIL
|
3 |
+
numpy
|
4 |
+
transformers==4.44.2
|
5 |
+
tensorflow==2.17.0
|
6 |
+
torch==2.4.1
|
7 |
+
torchvision==0.19.1
|
8 |
+
torchaudio==2.4.1
|