liturriago commited on
Commit
230646a
·
1 Parent(s): 55b6f51

ClassificationVCAPI\nAPI en HuggingFace Space con TensorFlow Serving-like pipeline.

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -9,16 +9,18 @@ app = FastAPI(title="TF Serving Base64 API")
9
  class ImagePayload(BaseModel):
10
  image_base64: str
11
 
 
 
 
 
12
  @app.post("/predict")
13
  def predict(payload: ImagePayload):
14
- # Decodificar base64
15
  img_bytes = base64.b64decode(payload.image_base64)
16
  img = tf.image.decode_image(img_bytes, channels=3)
17
  img = tf.image.resize(img, (224, 224))
18
  img = img / 255.0
19
  img = tf.expand_dims(img, 0)
20
 
21
- # Cargar modelo local
22
  model = tf.keras.models.load_model("model.keras")
23
 
24
  pred = model.predict(img).tolist()
 
9
  class ImagePayload(BaseModel):
10
  image_base64: str
11
 
12
+ @app.get("/")
13
+ def home():
14
+ return {"status": "ok", "message": "API is running! Use POST /predict"}
15
+
16
  @app.post("/predict")
17
  def predict(payload: ImagePayload):
 
18
  img_bytes = base64.b64decode(payload.image_base64)
19
  img = tf.image.decode_image(img_bytes, channels=3)
20
  img = tf.image.resize(img, (224, 224))
21
  img = img / 255.0
22
  img = tf.expand_dims(img, 0)
23
 
 
24
  model = tf.keras.models.load_model("model.keras")
25
 
26
  pred = model.predict(img).tolist()