Akash Chavda commited on
Commit
710136b
1 Parent(s): 1050dd5

feat: modal changes

Browse files
Files changed (2) hide show
  1. app.py +22 -16
  2. requirements.txt +2 -0
app.py CHANGED
@@ -1,22 +1,28 @@
 
1
  import os
2
  import gradio as gr
3
- import subprocess
4
 
5
- def install_dependencies():
6
- if not os.path.exists("project"):
7
- subprocess.run(["git", "clone", "https://github.com/luisesantillan/project"])
8
- subprocess.run(["pip", "install", "-r", "project/requirements.txt"])
9
- subprocess.run(["python", "project/download_files.py"])
 
 
 
 
 
 
10
 
11
- def start_tensorboard():
12
- if tensorboard:
13
- subprocess.Popen(["tensorboard", "--logdir", "./project/logs"])
14
 
15
- def run_app():
16
- subprocess.run(["python", "project/app.py", "--colab"])
 
 
 
17
 
18
- if __name__ == "__main__":
19
- tensorboard = True # Set this to True or False based on your requirement
20
- install_dependencies()
21
- start_tensorboard()
22
- run_app()
 
1
+ import subprocess
2
  import os
3
  import gradio as gr
 
4
 
5
+ # Step 1: Clone the GitHub repository and install requirements
6
+ if not os.path.exists("project"):
7
+ subprocess.run(["git", "clone", "https://github.com/luisesantillan/project"])
8
+ subprocess.run(["pip", "install", "-r", "project/requirements.txt"])
9
+ subprocess.run(["python", "project/download_files.py"])
10
+
11
+ # Step 2: Change directory to the project folder
12
+ os.chdir("project")
13
+
14
+ # Step 3: Start TensorBoard (if required)
15
+ tensorboard = True # Change this to False if you don't want to use TensorBoard
16
 
17
+ if tensorboard:
18
+ subprocess.Popen(["tensorboard", "--logdir", "./logs"])
 
19
 
20
+ # Step 4: Start the Gradio app
21
+ def gradio_app(input_text):
22
+ # Step 5: Run the app.py script with input_text as an argument
23
+ result = subprocess.run(["python", "app.py", "--colab", input_text], capture_output=True, text=True)
24
+ return result.stdout
25
 
26
+ # Create a Gradio interface
27
+ iface = gr.Interface(fn=gradio_app, inputs="text", outputs="text", live=True)
28
+ iface.launch()
 
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==2.1.0
2
+ tensorflow==2.7.0 # Make sure to specify your desired TensorFlow version