Denisijcu commited on
Commit
fa9a709
·
verified ·
1 Parent(s): c99f40a
Files changed (1) hide show
  1. app.py +15 -21
app.py CHANGED
@@ -1,27 +1,21 @@
1
- from flask import Flask, request, jsonify
2
  from huggingface_hub import InferenceClient
3
 
4
- app = Flask(__name__)
 
5
 
6
- client = InferenceClient()
 
 
 
7
 
8
- @app.route("/predict", methods=["POST"])
9
- def predict():
10
- if "file" not in request.files:
11
- return jsonify({"error": "Upload an image"}), 400
 
 
 
12
 
13
- img = request.files["file"].read()
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