File size: 2,568 Bytes
b0a0d6e
75000eb
8922a94
 
027e6e6
8922a94
 
 
 
027e6e6
8922a94
 
 
 
 
b6a1e5a
8922a94
b6a1e5a
9c91e2d
 
75000eb
90d0445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6057667
8922a94
 
 
 
 
90d0445
9c91e2d
 
 
6458b1f
6184a5d
9c91e2d
 
8922a94
b1d2555
9c91e2d
 
79406ef
 
90d0445
8922a94
79406ef
9c91e2d
027e6e6
6458b1f
 
8922a94
0738013
8922a94
 
 
1d245ae
8922a94
 
 
1d245ae
8922a94
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
print("Wait..")

# def test():
#     import gradio as gr
    
#     def analyze_text(text):
#         # Lakukan analisis atau pemrosesan teks di sini
#         result = f"Anda memasukkan teks: {text}"
#         return result
    
#     iface = gr.Interface(
#         fn=analyze_text,
#         inputs=gr.Textbox(),  # Menggunakan input textbox
#         outputs="text"  # Menetapkan output ke tipe teks
#     )

#     iface.launch()

def process():
    import subprocess

    def uninstall_and_install_gradio(version):
        # Uninstall current Gradio
        uninstall_command = ["pip", "uninstall", "gradio", "-y"]
        subprocess.run(uninstall_command)
        
        # Install specific version of Gradio
        install_command = ["pip", "install", f"gradio=={version}"]
        subprocess.run(install_command)
        
    # Gantilah "3.41.2" dengan versi Gradio yang diinginkan
    desired_version = "3.41.2"
        
    # Periksa versi Gradio yang terinstal
    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()
    
    # Cek dan lakukan uninstall dan install jika versi tidak sesuai
    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"
    
    # Argument yang ingin Anda tambahkan
    # additional_arguments = ["--disable-xformers", "--pytorch-deterministic", "--disable-ipex-hijack", "--disable-header-check", "--disable-async-cuda-allocation", "--disable-attention-upcast", "--always-offload-from-vram", "--all-in-fp32", "--always-no-vram"]
    additional_arguments = ["--always-cpu"]
    
    # Gabungkan semua argumen
    # PIP = ["pip", "install", "torch_directml"]
    command = ["python", python_script] + additional_arguments
    
    # Jalankan skrip menggunakan subprocess
    # print("Installing..")
    # subprocess.run(PIP)
    
    print(f"Running.. ({python_script})")
    subprocess.run(command)# Menjalankan file batch
    # subprocess.run([batch_file_path], shell=True)

process()

# launch = "process"

# if launch == "process":
#     process()
#     print("Loading..")
    
# elif launch == "test":
#     test()
#     print("Loading..")

# else:
#     print("ERROR!")