Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -1,27 +1,21 @@
|
|
| 1 |
-
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
result = client.image_classification(
|
| 16 |
-
model="google/vit-base-patch16-224",
|
| 17 |
-
inputs=img
|
| 18 |
-
)
|
| 19 |
-
|
| 20 |
-
return jsonify(result)
|
| 21 |
-
|
| 22 |
-
@app.route("/")
|
| 23 |
-
def home():
|
| 24 |
-
return "Running vit-base-patch16-224 Image Classifier 🚀"
|
| 25 |
-
|
| 26 |
-
if __name__ == "__main__":
|
| 27 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# Crear el cliente SIN API KEY
|
| 5 |
+
client = InferenceClient(model="google/vit-base-patch16-224")
|
| 6 |
|
| 7 |
+
def classify(img):
|
| 8 |
+
# Llamar a la inferencia nativa
|
| 9 |
+
result = client.image_classification(img)
|
| 10 |
+
return {item["label"]: item["score"] for item in result}
|
| 11 |
|
| 12 |
+
# UI mínima garantizada
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn=classify,
|
| 15 |
+
inputs=gr.Image(type="filepath"),
|
| 16 |
+
outputs=gr.Label(),
|
| 17 |
+
title="🔥 HF Free Model Test (No API Key)"
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
demo.launch()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|