arpandeepk commited on
Commit
f6d9c18
·
1 Parent(s): b604c19

Update app configuration for Hugging Face Spaces

Browse files
Files changed (2) hide show
  1. app.py +10 -7
  2. requirements.txt +3 -3
app.py CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
2
  import requests
3
  import os
4
 
5
- # API endpoint - replace with your VM's IP address
6
- API_URL = "http://34.42.197.123:8000/process_video" # Updated with your VM's IP
7
 
8
  def process_video(video_path, prompt):
9
  try:
@@ -21,6 +21,10 @@ def process_video(video_path, prompt):
21
 
22
  # Return the response
23
  return response.json()['response']
 
 
 
 
24
  except Exception as e:
25
  return f"Error: {str(e)}"
26
 
@@ -33,12 +37,11 @@ iface = gr.Interface(
33
  ],
34
  outputs=gr.Textbox(label="Model Response"),
35
  title="Video Analysis with VLM",
36
- description="Upload a video and ask questions about it. The model will analyze the first frame and respond to your prompt.",
37
  examples=[
38
- ["https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png", "What is going on in this image?"]
39
  ]
40
  )
41
 
42
- # Launch the app
43
- if __name__ == "__main__":
44
- iface.launch()
 
2
  import requests
3
  import os
4
 
5
+ # API endpoint - using environment variable with fallback
6
+ API_URL = os.getenv("API_URL", "http://34.58.134.224:8000/process_video")
7
 
8
  def process_video(video_path, prompt):
9
  try:
 
21
 
22
  # Return the response
23
  return response.json()['response']
24
+ except requests.exceptions.ConnectionError:
25
+ return "Error: Could not connect to the API server. Please try again later."
26
+ except requests.exceptions.RequestException as e:
27
+ return f"Error: API request failed - {str(e)}"
28
  except Exception as e:
29
  return f"Error: {str(e)}"
30
 
 
37
  ],
38
  outputs=gr.Textbox(label="Model Response"),
39
  title="Video Analysis with VLM",
40
+ description="Upload a video and ask questions about it. The model will analyze the video and respond to your prompt.",
41
  examples=[
42
+ ["https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.mp4", "What is happening in this video?"]
43
  ]
44
  )
45
 
46
+ # Launch the app for Hugging Face Spaces
47
+ iface.launch()
 
requirements.txt CHANGED
@@ -1,9 +1,9 @@
1
  gradio>=4.0.0
 
 
2
  opencv-python
3
  pillow
4
  torch
5
  prismatic
6
  fastapi
7
- uvicorn
8
- python-multipart
9
- requests
 
1
  gradio>=4.0.0
2
+ requests>=2.31.0
3
+ python-multipart>=0.0.6
4
  opencv-python
5
  pillow
6
  torch
7
  prismatic
8
  fastapi
9
+ uvicorn