Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
detection_pipeline = pipeline("image-classification", "Yuuki0/anime-cartoon-detect")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def detect(img):
|
| 8 |
+
output = detection_pipeline(img, top_k=2)
|
| 9 |
+
final = {}
|
| 10 |
+
for d in output:
|
| 11 |
+
final[d["label"]] = d["score"]
|
| 12 |
+
return final
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
iface = gr.Interface(fn=detect, inputs=gr.Image(type="pil"), outputs=gr.Label(label="result"))
|
| 16 |
+
iface.launch()
|