Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
# Define function for Gradio
|
| 8 |
def classify_image(img):
|
| 9 |
results = pipe(img)
|
| 10 |
return {res["label"]: float(res["score"]) for res in results}
|
| 11 |
|
| 12 |
-
# Gradio interface
|
| 13 |
demo = gr.Interface(
|
| 14 |
fn=classify_image,
|
| 15 |
-
inputs=gr.Image(type="filepath"),
|
| 16 |
-
outputs=gr.Label(num_top_classes=5),
|
| 17 |
-
title="
|
| 18 |
-
description="
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# Launch
|
| 22 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Wybierz l偶ejszy model
|
| 5 |
+
model_name = "facebook/deit-tiny-patch16-224"
|
| 6 |
+
|
| 7 |
+
pipe = pipeline("image-classification", model=model_name)
|
| 8 |
|
|
|
|
| 9 |
def classify_image(img):
|
| 10 |
results = pipe(img)
|
| 11 |
return {res["label"]: float(res["score"]) for res in results}
|
| 12 |
|
|
|
|
| 13 |
demo = gr.Interface(
|
| 14 |
fn=classify_image,
|
| 15 |
+
inputs=gr.Image(type="filepath"),
|
| 16 |
+
outputs=gr.Label(num_top_classes=5),
|
| 17 |
+
title="Lekka klasyfikacja obraz贸w",
|
| 18 |
+
description=f"Model: {model_name}"
|
| 19 |
)
|
| 20 |
|
|
|
|
| 21 |
demo.launch()
|