|
print("Wait..") |
|
|
|
def test(): |
|
import gradio as gr |
|
|
|
def analyze_text(text): |
|
|
|
result = f"Anda memasukkan teks: {text}" |
|
return result |
|
|
|
iface = gr.Interface( |
|
fn=analyze_text, |
|
inputs=gr.Textbox(), |
|
outputs="text" |
|
) |
|
|
|
iface.launch() |
|
|
|
def process(): |
|
import subprocess |
|
|
|
def uninstall_and_install_gradio(version): |
|
|
|
uninstall_command = ["pip", "uninstall", "gradio", "-y"] |
|
subprocess.run(uninstall_command) |
|
|
|
|
|
install_command = ["pip", "install", f"gradio=={version}"] |
|
subprocess.run(install_command) |
|
|
|
|
|
desired_version = "3.41.2" |
|
|
|
|
|
current_version_command = ["pip", "show", "gradio"] |
|
result = subprocess.run(current_version_command, capture_output=True, text=True) |
|
current_version = None |
|
|
|
if "Version" in result.stdout: |
|
current_version = result.stdout.split("Version:")[1].strip() |
|
|
|
|
|
if current_version != desired_version: |
|
uninstall_and_install_gradio(desired_version) |
|
print(f"Gradio has been updated to version {desired_version}") |
|
else: |
|
print(f"Gradio is already at version {desired_version}") |
|
|
|
python_script = "entry_with_update.py" |
|
|
|
|
|
|
|
additional_arguments = ["--always-cpu", "--attention-split", "--disable-in-browser", "--multi-user", "--always-download-new-model", "--share"] |
|
|
|
|
|
PIP = ["pip", "install", "-r", "requirements.txt"] |
|
command = ["python", python_script] + additional_arguments |
|
|
|
|
|
print("Installing..") |
|
subprocess.run(PIP) |
|
|
|
print("Running..") |
|
subprocess.run(command) |
|
|
|
|
|
process() |