Spaces:
Sleeping
Sleeping
Commit
·
139ed0e
1
Parent(s):
ddab47a
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
-
def predict(image):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
iface = gr.Interface(
|
| 12 |
fn=predict,
|
| 13 |
-
inputs=gr.inputs.Image(type='filepath'),
|
| 14 |
-
outputs='label', interpretation='
|
| 15 |
|
| 16 |
iface.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from huggingface_hub import hf_api
|
| 4 |
+
from huggingface_hub import DatasetFilter, ModelFilter
|
| 5 |
|
| 6 |
+
api = hf_api.HfApi()
|
| 7 |
+
flyswot_models = ModelFilter(author="flyswot")
|
| 8 |
+
models = api.list_models(filter=flyswot_models)
|
| 9 |
+
models = [model.modelId for model in models]
|
| 10 |
+
choices = gr.inputs.Dropdown(choices=models, default='flyswot/convnext-tiny-224_flyswot',label="Model")
|
| 11 |
|
| 12 |
|
| 13 |
+
def predict(image,model):
|
| 14 |
+
pipe = pipeline("image-classification", model=model)
|
| 15 |
+
predictions = pipe(image)
|
| 16 |
+
return {pred['label']: pred['score'] for pred in predictions}
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=predict,
|
| 20 |
+
inputs=[gr.inputs.Image(type='filepath'),choices],
|
| 21 |
+
outputs='label', interpretation='shap')
|
| 22 |
|
| 23 |
iface.launch()
|
| 24 |
+
|