zacbouhnik
commited on
Commit
•
da54acc
1
Parent(s):
66cb296
second test
Browse files
app.py
CHANGED
@@ -1,8 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!"
|
5 |
|
6 |
-
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from transformers import pipeline, AutoModelForImageClassification, AutoFeatureExtractor
|
|
|
4 |
|
5 |
+
HF_MODEL_PATH = (
|
6 |
+
"ImageIN/convnext-base-224_finetuned_on_unlabelled_IA_with_snorkel_labels"
|
7 |
+
)
|
8 |
|
9 |
+
classif_model = AutoModelForImageClassification.from_pretrained(HF_MODEL_PATH)
|
10 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(HF_MODEL_PATH)
|
11 |
+
|
12 |
+
classif_pipeline = pipeline(
|
13 |
+
"image-classification", model=classif_model, feature_extractor=feature_extractor
|
14 |
+
)
|
15 |
+
|
16 |
+
demo = gr.Interface(
|
17 |
+
fn=lambda x: classif_pipeline(x)[0]["label"],
|
18 |
+
inputs=gr.Image(type="pil"),
|
19 |
+
outputs="text",
|
20 |
+
)
|
21 |
+
demo.launch()
|