Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
print("Wait..")
|
2 |
+
|
3 |
+
def test():
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
def analyze_text(text):
|
7 |
+
# Lakukan analisis atau pemrosesan teks di sini
|
8 |
+
result = f"Anda memasukkan teks: {text}"
|
9 |
+
return result
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=analyze_text,
|
13 |
+
inputs=gr.Textbox(), # Menggunakan input textbox
|
14 |
+
outputs="text" # Menetapkan output ke tipe teks
|
15 |
+
)
|
16 |
+
|
17 |
+
iface.launch()
|
18 |
+
|
19 |
+
def process():
|
20 |
+
import subprocess
|
21 |
+
|
22 |
+
# def uninstall_and_install_gradio(version):
|
23 |
+
# # Uninstall current Gradio
|
24 |
+
# uninstall_command = ["pip", "uninstall", "gradio", "-y"]
|
25 |
+
# subprocess.run(uninstall_command)
|
26 |
+
|
27 |
+
# # Install specific version of Gradio
|
28 |
+
# install_command = ["pip", "install", f"gradio=={version}"]
|
29 |
+
# subprocess.run(install_command)
|
30 |
+
|
31 |
+
# # Gantilah "3.41.2" dengan versi Gradio yang diinginkan
|
32 |
+
# desired_version = "3.41.2"
|
33 |
+
|
34 |
+
# # Periksa versi Gradio yang terinstal
|
35 |
+
# current_version_command = ["pip", "show", "gradio"]
|
36 |
+
# result = subprocess.run(current_version_command, capture_output=True, text=True)
|
37 |
+
# current_version = None
|
38 |
+
|
39 |
+
# if "Version" in result.stdout:
|
40 |
+
# current_version = result.stdout.split("Version:")[1].strip()
|
41 |
+
|
42 |
+
# # Cek dan lakukan uninstall dan install jika versi tidak sesuai
|
43 |
+
# if current_version != desired_version:
|
44 |
+
# uninstall_and_install_gradio(desired_version)
|
45 |
+
# print(f"Gradio has been updated to version {desired_version}")
|
46 |
+
# else:
|
47 |
+
# print(f"Gradio is already at version {desired_version}")
|
48 |
+
|
49 |
+
python_script = "entry_with_update.py"
|
50 |
+
|
51 |
+
# Argument yang ingin Anda tambahkan
|
52 |
+
# additional_arguments = ["--in-browser", "--all-in-fp32", "--directml", "--debug-mode", "--multi-user", "--always-cpu", "--is-windows-embedded-python"]
|
53 |
+
additional_arguments = ["--always-cpu", "--attention-split", "--always-download-new-model", "--disable-in-browser"]
|
54 |
+
|
55 |
+
# Gabungkan semua argumen
|
56 |
+
PIP0 = ["pip", "install", "--upgrade", "pip"]
|
57 |
+
PIP1 = ["pip", "install", "-r", "requirements_versions.txt"]
|
58 |
+
command = ["python", python_script] + additional_arguments
|
59 |
+
|
60 |
+
# Jalankan skrip menggunakan subprocess
|
61 |
+
|
62 |
+
print("Installing..")
|
63 |
+
subprocess.run(PIP0)
|
64 |
+
subprocess.run(PIP1)
|
65 |
+
|
66 |
+
print("Running..")
|
67 |
+
subprocess.run(command) # Menjalankan file batch
|
68 |
+
# subprocess.run([batch_file_path], shell=True)
|
69 |
+
|
70 |
+
process()
|