Spaces:
Sleeping
Sleeping
import subprocess | |
import os | |
import gradio as gr | |
# Step 1: Clone the GitHub repository and install requirements | |
if not os.path.exists("project"): | |
subprocess.run(["git", "clone", "https://github.com/luisesantillan/project"]) | |
subprocess.run(["pip", "install", "-r", "project/requirements.txt"]) | |
subprocess.run(["python", "project/download_files.py"]) | |
# Step 2: Change directory to the project folder | |
os.chdir("project") | |
# Step 3: Start TensorBoard (if required) | |
tensorboard = True # Change this to False if you don't want to use TensorBoard | |
if tensorboard: | |
subprocess.Popen(["tensorboard", "--logdir", "./logs"]) | |
# Step 4: Start the Gradio app | |
def gradio_app(input_text): | |
# Step 5: Run the app.py script with input_text as an argument | |
result = subprocess.run(["python", "app.py", "--colab", input_text], capture_output=True, text=True) | |
return result.stdout | |
# Create a Gradio interface | |
iface = gr.Interface(fn=gradio_app, inputs="text", outputs="text", live=True) | |
iface.launch() | |