Amarthya7 commited on
Commit
d9829a0
·
verified ·
1 Parent(s): 5b6f1b6

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +15 -32
run.py CHANGED
@@ -40,11 +40,6 @@ def ensure_directories():
40
  os.makedirs(logs_dir, exist_ok=True)
41
 
42
 
43
- def is_huggingface_space():
44
- """Check if the app is running on Hugging Face Spaces"""
45
- return "SPACE_ID" in os.environ
46
-
47
-
48
  def main():
49
  """Main function to run the application"""
50
  print("Visual Question Answering - Multi-Modal AI Application with Streamlit")
@@ -74,33 +69,21 @@ def main():
74
  print("Press Ctrl+C to exit")
75
 
76
  # Run the Streamlit app
77
- if is_huggingface_space():
78
- # In Hugging Face Spaces, we don't need to launch Streamlit manually
79
- # Just import the app and it will be picked up by Streamlit when this script is run
80
- print("Running in Hugging Face Spaces environment")
81
- sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
82
- try:
83
- # This will make the app importable by Streamlit
84
- pass
85
- except Exception as e:
86
- print(f"Error importing app.py: {e}")
87
- else:
88
- # For local development, we launch Streamlit via subprocess
89
- cmd = [
90
- "streamlit",
91
- "run",
92
- app_path,
93
- "--server.port",
94
- str(port),
95
- "--server.address",
96
- "0.0.0.0",
97
- ]
98
- try:
99
- subprocess.run(cmd)
100
- except KeyboardInterrupt:
101
- print("\nShutting down the application...")
102
- except Exception as e:
103
- print(f"Error launching Streamlit: {e}")
104
 
105
 
106
  if __name__ == "__main__":
 
40
  os.makedirs(logs_dir, exist_ok=True)
41
 
42
 
 
 
 
 
 
43
  def main():
44
  """Main function to run the application"""
45
  print("Visual Question Answering - Multi-Modal AI Application with Streamlit")
 
69
  print("Press Ctrl+C to exit")
70
 
71
  # Run the Streamlit app
72
+ cmd = [
73
+ "streamlit",
74
+ "run",
75
+ app_path,
76
+ "--server.port",
77
+ str(port),
78
+ "--server.address",
79
+ "0.0.0.0",
80
+ ]
81
+ try:
82
+ subprocess.run(cmd)
83
+ except KeyboardInterrupt:
84
+ print("\nShutting down the application...")
85
+ except Exception as e:
86
+ print(f"Error launching Streamlit: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
 
89
  if __name__ == "__main__":