vidhi0405 commited on
Commit
6deb156
·
1 Parent(s): 1223036
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -20,6 +20,7 @@ os.environ['HUGGINGFACE_HUB_CACHE'] = CACHE_DIR
20
  os.environ['TOKENIZERS_PARALLELISM'] = 'false'
21
 
22
  from fastapi import FastAPI, UploadFile, File, HTTPException
 
23
  from fastapi.middleware.cors import CORSMiddleware
24
  from pydantic import BaseModel
25
  import sys
@@ -59,6 +60,7 @@ class AnalysisResponse(BaseModel):
59
  success: bool
60
  message: str
61
  video_description: str
 
62
  analysis_file: str
63
 
64
  # Create output directories with proper permissions
@@ -74,6 +76,15 @@ async def health_check():
74
  """Health check endpoint"""
75
  return {"status": "healthy", "model": "SmolVLM2-256M-Video-Instruct"}
76
 
 
 
 
 
 
 
 
 
 
77
  @app.post("/upload-video", response_model=AnalysisResponse)
78
  async def upload_video(
79
  video: UploadFile = File(...),
@@ -124,6 +135,7 @@ async def upload_video(
124
  success=True,
125
  message="Video description generated successfully",
126
  video_description=results.get("video_description", ""),
 
127
  analysis_file=analysis_path
128
  )
129
  except Exception as e:
 
20
  os.environ['TOKENIZERS_PARALLELISM'] = 'false'
21
 
22
  from fastapi import FastAPI, UploadFile, File, HTTPException
23
+ from fastapi.responses import FileResponse
24
  from fastapi.middleware.cors import CORSMiddleware
25
  from pydantic import BaseModel
26
  import sys
 
60
  success: bool
61
  message: str
62
  video_description: str
63
+ highlights: str
64
  analysis_file: str
65
 
66
  # Create output directories with proper permissions
 
76
  """Health check endpoint"""
77
  return {"status": "healthy", "model": "SmolVLM2-256M-Video-Instruct"}
78
 
79
+ @app.get("/tmp/outputs/{filename}")
80
+ async def get_output_file(filename: str):
81
+ """Serve generated files from /tmp/outputs."""
82
+ safe_name = os.path.basename(filename)
83
+ file_path = os.path.join(OUTPUTS_DIR, safe_name)
84
+ if not os.path.exists(file_path):
85
+ raise HTTPException(status_code=404, detail="File not found")
86
+ return FileResponse(path=file_path, filename=safe_name)
87
+
88
  @app.post("/upload-video", response_model=AnalysisResponse)
89
  async def upload_video(
90
  video: UploadFile = File(...),
 
135
  success=True,
136
  message="Video description generated successfully",
137
  video_description=results.get("video_description", ""),
138
+ highlights=output_path,
139
  analysis_file=analysis_path
140
  )
141
  except Exception as e: