tezuesh commited on
Commit
b368588
·
verified ·
1 Parent(s): c80e261

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. server.py +7 -5
server.py CHANGED
@@ -31,7 +31,7 @@ class EmbeddingRequest(BaseModel):
31
  embedding: List[float]
32
 
33
  class TextResponse(BaseModel):
34
- text: str = ""
35
 
36
  # Model initialization status
37
  INITIALIZATION_STATUS = {
@@ -124,10 +124,14 @@ async def inference(request: EmbeddingRequest) -> TextResponse:
124
  logger.info(f"Converted embedding to tensor with shape: {embedding.shape}")
125
 
126
  # Run inference
127
- result = inference_recipe.generate_batch(cfg=cfg, video_ib_embed=embedding)
128
  logger.info("Generation complete")
129
 
130
- return TextResponse(text=result)
 
 
 
 
131
 
132
  except Exception as e:
133
  logger.error(f"Inference failed: {str(e)}", exc_info=True)
@@ -140,5 +144,3 @@ if __name__ == "__main__":
140
  import uvicorn
141
  uvicorn.run(app, host="0.0.0.0", port=8000)
142
 
143
-
144
-
 
31
  embedding: List[float]
32
 
33
  class TextResponse(BaseModel):
34
+ texts: List[str] = []
35
 
36
  # Model initialization status
37
  INITIALIZATION_STATUS = {
 
124
  logger.info(f"Converted embedding to tensor with shape: {embedding.shape}")
125
 
126
  # Run inference
127
+ results = inference_recipe.generate_batch(cfg=cfg, video_ib_embed=embedding)
128
  logger.info("Generation complete")
129
 
130
+ # Convert results to list if it's not already
131
+ if isinstance(results, str):
132
+ results = [results]
133
+
134
+ return TextResponse(texts=results)
135
 
136
  except Exception as e:
137
  logger.error(f"Inference failed: {str(e)}", exc_info=True)
 
144
  import uvicorn
145
  uvicorn.run(app, host="0.0.0.0", port=8000)
146