Update app.py
Browse files
app.py
CHANGED
|
@@ -10,28 +10,7 @@ uid = uuid.uuid4()
|
|
| 10 |
#token_self = os.environ['HF_TOKEN']
|
| 11 |
o=os.environ['P']
|
| 12 |
model_list = [
|
| 13 |
-
|
| 14 |
-
"CompVis/stable-diffusion-v1-4",
|
| 15 |
-
"runwayml/stable-diffusion-v1-5",
|
| 16 |
-
"prompthero/openjourney",
|
| 17 |
-
"stabilityai/stable-diffusion-2-1",
|
| 18 |
-
"stabilityai/stable-diffusion-2-1-base",
|
| 19 |
-
"andite/anything-v4.0",
|
| 20 |
-
"Linaqruf/anything-v3.0",
|
| 21 |
-
"eimiss/EimisAnimeDiffusion_1.0v",
|
| 22 |
-
"nitrosocke/Nitro-Diffusion",
|
| 23 |
-
"wavymulder/portraitplus",
|
| 24 |
-
"22h/vintedois-diffusion-v0-1",
|
| 25 |
-
"dreamlike-art/dreamlike-photoreal-2.0",
|
| 26 |
-
"dreamlike-art/dreamlike-diffusion-1.0",
|
| 27 |
-
"wavymulder/Analog-Diffusion",
|
| 28 |
-
"nitrosocke/redshift-diffusion",
|
| 29 |
-
"claudfuen/photorealistic-fuen-v1",
|
| 30 |
-
"prompthero/openjourney-v2",
|
| 31 |
-
"johnslegers/epic-diffusion",
|
| 32 |
-
"nitrosocke/Arcane-Diffusion",
|
| 33 |
-
"darkstorm2150/Protogen_x5.8_Official_Release",
|
| 34 |
-
|
| 35 |
]
|
| 36 |
|
| 37 |
types=[
|
|
@@ -40,9 +19,26 @@ types=[
|
|
| 40 |
"C",
|
| 41 |
"R1",
|
| 42 |
]
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
uid = uuid.uuid4()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
model_id=t_name
|
| 47 |
if token==None or token=="":
|
| 48 |
token = token_self
|
|
@@ -57,10 +53,7 @@ def build_space(token,t_name,s_type,m_type=None,r_type=None,d_app=None,d_css=Non
|
|
| 57 |
try:
|
| 58 |
api_url = f'https://huggingface.co/api/spaces/{model_id}'
|
| 59 |
if s_type == "A":
|
| 60 |
-
|
| 61 |
-
file = open(f'tmp_file{uid}.txt','w')
|
| 62 |
-
file.writelines(r.text)
|
| 63 |
-
file.close()
|
| 64 |
|
| 65 |
with open(f'tmp_file{uid}.txt', "r") as f:
|
| 66 |
app = f.read()
|
|
@@ -101,19 +94,24 @@ with gr.Blocks() as build:
|
|
| 101 |
with gr.Box():
|
| 102 |
token = gr.Textbox(label="auth")
|
| 103 |
t_name = gr.Textbox(label="Space Name")
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
with gr.Row():
|
| 113 |
-
inbut = gr.Button()
|
| 114 |
output_html = gr.HTML("""""")
|
| 115 |
files=gr.File()
|
| 116 |
gr.Column(scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
pass_btn.click(checkp,pass_box,[no,yes])
|
| 118 |
inbut.click(build_space,[token,t_name,s_type,m_type,r_type,d_app,d_css],output_html)
|
| 119 |
build.queue(concurrency_count=10).launch()
|
|
|
|
| 10 |
#token_self = os.environ['HF_TOKEN']
|
| 11 |
o=os.environ['P']
|
| 12 |
model_list = [
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
]
|
| 15 |
|
| 16 |
types=[
|
|
|
|
| 19 |
"C",
|
| 20 |
"R1",
|
| 21 |
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def load_space(t_name)
|
| 26 |
uid = uuid.uuid4()
|
| 27 |
+
r = requests.get(f'https://huggingface.co/spaces/{model_id}/raw/main/{d_app}')
|
| 28 |
+
file = open(f'tmp_file{uid}.txt','w')
|
| 29 |
+
file.writelines(r.text)
|
| 30 |
+
file.close()
|
| 31 |
+
return r.text, uid
|
| 32 |
+
def rep_l(rs,rt,uu):
|
| 33 |
+
file = open(f'tmp_file{uu}.txt','r')
|
| 34 |
+
r_file = file.read()
|
| 35 |
+
r_file = file.replace(f'{rs}',f'{rt}')
|
| 36 |
+
return r_file
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def build_space(token,t_name,s_type,m_type=None,r_type=None,d_app=None,d_css=None):
|
| 42 |
model_id=t_name
|
| 43 |
if token==None or token=="":
|
| 44 |
token = token_self
|
|
|
|
| 53 |
try:
|
| 54 |
api_url = f'https://huggingface.co/api/spaces/{model_id}'
|
| 55 |
if s_type == "A":
|
| 56 |
+
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
with open(f'tmp_file{uid}.txt', "r") as f:
|
| 59 |
app = f.read()
|
|
|
|
| 94 |
with gr.Box():
|
| 95 |
token = gr.Textbox(label="auth")
|
| 96 |
t_name = gr.Textbox(label="Space Name")
|
| 97 |
+
d_app = gr.Textbox(label="File", value="app.py")
|
| 98 |
+
l_btn = gr.Button("Load")
|
| 99 |
+
with gr.Box():
|
| 100 |
+
r_s = gr.Textbox(label="Replace")
|
| 101 |
+
r_w = gr.Textbox(label="with:")
|
| 102 |
+
r_btn = gr.Button("Replace")
|
| 103 |
+
with gr.Row():
|
| 104 |
+
inbut = gr.Button()
|
|
|
|
|
|
|
| 105 |
output_html = gr.HTML("""""")
|
| 106 |
files=gr.File()
|
| 107 |
gr.Column(scale=1)
|
| 108 |
+
with gr.Row():
|
| 109 |
+
r_t=gr.Textbox(max_lines=100)
|
| 110 |
+
m_t=gr.Textbox(max_lines=100)
|
| 111 |
+
uu=gr.Textbox(visible=False)
|
| 112 |
+
l_btn.click(load_space,[t_name,d_app],[r_t,uu])
|
| 113 |
+
r_btn.click(repl,[r_s,r_w,uu], m_t)
|
| 114 |
+
|
| 115 |
pass_btn.click(checkp,pass_box,[no,yes])
|
| 116 |
inbut.click(build_space,[token,t_name,s_type,m_type,r_type,d_app,d_css],output_html)
|
| 117 |
build.queue(concurrency_count=10).launch()
|