liuyizhang commited on
Commit
aa3eb9a
·
1 Parent(s): da50165

update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -1,17 +1,22 @@
1
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
2
  import gradio as gr
3
  import random
4
  import string
5
  # import paddlehub as hub
6
  import torch
7
- from transformers import AutoModelForCausalLM, AutoTokenizer
8
  from loguru import logger
9
 
10
  from utils import get_tmt_client, getTextTrans_tmt
11
- import subprocess
12
-
13
- result = subprocess.run(['pip', 'list'], check=True)
14
- print(f'pip list = {result}')
15
 
16
  tmt_client = get_tmt_client()
17
 
@@ -36,9 +41,9 @@ def getTextTrans(text, source='zh', target='en'):
36
  space_ids = {
37
  "spaces/stabilityai/stable-diffusion": "SD 2.1",
38
  "spaces/runwayml/stable-diffusion-v1-5": "SD 1.5",
39
- "spaces/stabilityai/stable-diffusion-1": "SD 1.0",
40
- "dalle_mini_tab": "Dalle mini",
41
- "spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese": "Taiyi(太乙)",
42
  }
43
 
44
  tab_actions = []
@@ -95,20 +100,25 @@ if do_dreamlike_photoreal:
95
  tab_titles.append("Dreamlike_2.0")
96
  thanks_info += "[<a style='display:inline-block' href='https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0' _blank><font style='color:blue;weight:bold;'>dreamlike-photoreal-2.0</font></a>]"
97
 
98
- for space_id in space_ids.keys():
99
- print(space_id, space_ids[space_id])
 
 
 
100
  try:
101
- tab_title = space_ids[space_id]
102
- tab_titles.append(tab_title)
103
  if (tab_title == 'Dalle mini'):
104
  tab_content = gr.Blocks(elem_id='dalle_mini')
 
105
  tab_actions.append(tab_content)
106
  else:
107
  tab_content = gr.Interface.load(space_id)
108
- tab_actions.append(tab_content)
 
109
  thanks_info += f"[<a style='display:inline-block' href='https://huggingface.co/{space_id}' _blank><font style='color:blue;weight:bold;'>{tab_title}</font></a>]"
 
110
  except Exception as e:
111
- logger.info(f"load_fail__{space_id}_{e}")
112
 
113
  start_work = """async() => {
114
  function isMobile() {
@@ -174,7 +184,7 @@ start_work = """async() => {
174
  } else if (tabitems_title[i].innerText.indexOf('Dreamlike') >= 0 && tabitems[i].childNodes[0].children.length > 0) {
175
  tabitems[i].childNodes[0].children[0].children[1].style.display='none';
176
  } else if (tabitems_title[i].innerText.indexOf('Dalle mini') >= 0) {
177
- window['dalle_mini_block']= tabitems[i];
178
  }
179
  }
180
 
@@ -228,10 +238,10 @@ start_work = """async() => {
228
  continue;
229
  }
230
  inputText = null;
231
- if (tabitems_title[i].innerText.indexOf('SD') >= 0) {
232
  text_value = window['gradioEl'].querySelectorAll('#prompt_work')[0].querySelectorAll('textarea')[0].value;
233
  inputText = tabitems[i].children[0].children[1].children[0].querySelectorAll('.gr-text-input')[0];
234
- } else if (tabitems_title[i].innerText.indexOf('Taiyi') >= 0) {
235
  text_value = window['gradioEl'].querySelectorAll('#prompt_work_zh')[0].querySelectorAll('textarea')[0].value;
236
  inputText = tabitems[i].children[0].children[0].children[1].querySelectorAll('.gr-text-input')[0];
237
  }
 
1
+ import subprocess, os
2
+
3
+ result = subprocess.run(['pip', 'list'], check=True)
4
+ print(f'pip list_1_ = {result}')
5
+
6
+ os.system("pip install httpx==0.24.1")
7
+
8
+ result = subprocess.run(['pip', 'list'], check=True)
9
+ print(f'pip list_2_ = {result}')
10
+
11
  import gradio as gr
12
  import random
13
  import string
14
  # import paddlehub as hub
15
  import torch
16
+ from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
17
  from loguru import logger
18
 
19
  from utils import get_tmt_client, getTextTrans_tmt
 
 
 
 
20
 
21
  tmt_client = get_tmt_client()
22
 
 
41
  space_ids = {
42
  "spaces/stabilityai/stable-diffusion": "SD 2.1",
43
  "spaces/runwayml/stable-diffusion-v1-5": "SD 1.5",
44
+ # "spaces/stabilityai/stable-diffusion-1": "SD 1.0",
45
+ # "dalle_mini_tab": "Dalle mini",
46
+ # "spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese": "Taiyi(太乙)",
47
  }
48
 
49
  tab_actions = []
 
100
  tab_titles.append("Dreamlike_2.0")
101
  thanks_info += "[<a style='display:inline-block' href='https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0' _blank><font style='color:blue;weight:bold;'>dreamlike-photoreal-2.0</font></a>]"
102
 
103
+ space_ids_keys = space_ids.keys()
104
+ logger.info(f"load_space__000__{space_ids_keys}")
105
+ for space_id in space_ids_keys:
106
+ logger.info(f"load_space__{space_id}__{space_ids[space_id]}")
107
+ tab_title = ''
108
  try:
109
+ tab_title = space_ids[space_id]
 
110
  if (tab_title == 'Dalle mini'):
111
  tab_content = gr.Blocks(elem_id='dalle_mini')
112
+ tab_titles.append(tab_title)
113
  tab_actions.append(tab_content)
114
  else:
115
  tab_content = gr.Interface.load(space_id)
116
+ tab_titles.append(tab_title)
117
+ tab_actions.append(tab_content)
118
  thanks_info += f"[<a style='display:inline-block' href='https://huggingface.co/{space_id}' _blank><font style='color:blue;weight:bold;'>{tab_title}</font></a>]"
119
+ logger.info(f"load_sucessful__{space_id}__{tab_title}")
120
  except Exception as e:
121
+ logger.info(f"load_fail__{space_id}__{tab_title}____{e}")
122
 
123
  start_work = """async() => {
124
  function isMobile() {
 
184
  } else if (tabitems_title[i].innerText.indexOf('Dreamlike') >= 0 && tabitems[i].childNodes[0].children.length > 0) {
185
  tabitems[i].childNodes[0].children[0].children[1].style.display='none';
186
  } else if (tabitems_title[i].innerText.indexOf('Dalle mini') >= 0) {
187
+ window['dalle_mini_block'] = tabitems[i];
188
  }
189
  }
190
 
 
238
  continue;
239
  }
240
  inputText = null;
241
+ if (tabitems_title[i].innerText.indexOf('SD') >= 0 && tabitems[i].childNodes[0].children.length > 0) {
242
  text_value = window['gradioEl'].querySelectorAll('#prompt_work')[0].querySelectorAll('textarea')[0].value;
243
  inputText = tabitems[i].children[0].children[1].children[0].querySelectorAll('.gr-text-input')[0];
244
+ } else if (tabitems_title[i].innerText.indexOf('Taiyi') >= 0 && tabitems[i].childNodes[0].children.length > 0) {
245
  text_value = window['gradioEl'].querySelectorAll('#prompt_work_zh')[0].querySelectorAll('textarea')[0].value;
246
  inputText = tabitems[i].children[0].children[0].children[1].querySelectorAll('.gr-text-input')[0];
247
  }