Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,19 +65,23 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
65 |
return seed
|
66 |
|
67 |
def translateEN(zh):
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
|
76 |
def process_text(prompt):
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
81 |
|
82 |
@spaces.GPU
|
83 |
def generate(
|
@@ -106,12 +110,18 @@ def generate(
|
|
106 |
if not use_negative_prompt_2:
|
107 |
negative_prompt_2 = None # type: ignore
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
if not apply_refiner:
|
110 |
return pipe(
|
111 |
-
prompt=
|
112 |
-
negative_prompt=
|
113 |
-
prompt_2=
|
114 |
-
negative_prompt_2=
|
115 |
width=width,
|
116 |
height=height,
|
117 |
guidance_scale=guidance_scale_base,
|
@@ -121,10 +131,10 @@ def generate(
|
|
121 |
).images[0]
|
122 |
else:
|
123 |
latents = pipe(
|
124 |
-
prompt=
|
125 |
-
negative_prompt=
|
126 |
-
prompt_2=
|
127 |
-
negative_prompt_2=
|
128 |
width=width,
|
129 |
height=height,
|
130 |
guidance_scale=guidance_scale_base,
|
@@ -133,10 +143,10 @@ def generate(
|
|
133 |
output_type="latent",
|
134 |
).images
|
135 |
image = refiner(
|
136 |
-
prompt=
|
137 |
-
negative_prompt=
|
138 |
-
prompt_2=
|
139 |
-
negative_prompt_2=
|
140 |
guidance_scale=guidance_scale_refiner,
|
141 |
num_inference_steps=num_inference_steps_refiner,
|
142 |
image=latents,
|
|
|
65 |
return seed
|
66 |
|
67 |
def translateEN(zh):
|
68 |
+
if zh:
|
69 |
+
result = requests.post(
|
70 |
+
"https://api-free.deepl.com/v2/translate",
|
71 |
+
params={
|
72 |
+
"auth_key": "e8b4d428-ada5-3f8d-f965-bad01e8a06c1:fx",
|
73 |
+
"target_lang": "EN-US",
|
74 |
+
"text": zh})
|
75 |
+
return result.json()["translations"][0]["text"]
|
76 |
|
77 |
def process_text(prompt):
|
78 |
+
if prompt:
|
79 |
+
print("中文提示词: \n", prompt)
|
80 |
+
prompt_trans = translateEN(prompt)
|
81 |
+
print("prompt: \n", prompt_trans)
|
82 |
+
return prompt_trans
|
83 |
+
|
84 |
+
process_text("外面做一个测试")
|
85 |
|
86 |
@spaces.GPU
|
87 |
def generate(
|
|
|
110 |
if not use_negative_prompt_2:
|
111 |
negative_prompt_2 = None # type: ignore
|
112 |
|
113 |
+
process_text("里面做一个测试")
|
114 |
+
print("prompt是:", prompt)
|
115 |
+
print("negative_prompt是:", negative_prompt)
|
116 |
+
print("prompt_2是:", prompt_2)
|
117 |
+
print("negative_prompt_2是:", negative_prompt_2)
|
118 |
+
|
119 |
if not apply_refiner:
|
120 |
return pipe(
|
121 |
+
prompt=prompt,
|
122 |
+
negative_prompt=negative_prompt,
|
123 |
+
prompt_2=prompt_2,
|
124 |
+
negative_prompt_2=negative_prompt_2,
|
125 |
width=width,
|
126 |
height=height,
|
127 |
guidance_scale=guidance_scale_base,
|
|
|
131 |
).images[0]
|
132 |
else:
|
133 |
latents = pipe(
|
134 |
+
prompt=prompt,
|
135 |
+
negative_prompt=negative_prompt,
|
136 |
+
prompt_2=prompt_2,
|
137 |
+
negative_prompt_2=negative_prompt_2,
|
138 |
width=width,
|
139 |
height=height,
|
140 |
guidance_scale=guidance_scale_base,
|
|
|
143 |
output_type="latent",
|
144 |
).images
|
145 |
image = refiner(
|
146 |
+
prompt=prompt,
|
147 |
+
negative_prompt=negative_prompt,
|
148 |
+
prompt_2=prompt_2,
|
149 |
+
negative_prompt_2=negative_prompt_2,
|
150 |
guidance_scale=guidance_scale_refiner,
|
151 |
num_inference_steps=num_inference_steps_refiner,
|
152 |
image=latents,
|