Spaces:
Runtime error
Runtime error
Commit
·
e83348e
1
Parent(s):
2684052
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,344 +1,15 @@
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
-
"""
|
| 3 |
|
| 4 |
Automatically generated by Colaboratory.
|
| 5 |
|
| 6 |
Original file is located at
|
| 7 |
-
https://colab.research.google.com/drive/
|
| 8 |
"""
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 12 |
-
|
| 13 |
-
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-zh-en")
|
| 14 |
-
|
| 15 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-zh-en")
|
| 16 |
-
|
| 17 |
import gradio as gr
|
| 18 |
-
import
|
| 19 |
-
from PIL import Image
|
| 20 |
-
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, DPMSolverMultistepScheduler, StableDiffusionImg2ImgPipeline
|
| 21 |
-
|
| 22 |
-
import torch
|
| 23 |
-
from controlnet_aux import HEDdetector
|
| 24 |
-
from diffusers.utils import load_image
|
| 25 |
-
|
| 26 |
-
import concurrent.futures
|
| 27 |
-
from threading import Thread
|
| 28 |
-
from compel import Compel
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
from transformers import pipeline
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
model_ckpt = "papluca/xlm-roberta-base-language-detection"
|
| 35 |
-
pipe = pipeline("text-classification", model=model_ckpt)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
device="cuda" if torch.cuda.is_available() else "cpu"
|
| 40 |
-
|
| 41 |
-
hidden_booster_text = ", loraeyes, beautiful face, small boobs, a cup"
|
| 42 |
-
hidden_negative = "big boobs, huge boobs, sexy, dirty, d cup, e cup, g cup, slutty, badhandv4, ng_deepnegative_v1_75t, worst quality, low quality, extra digits, text, signature, bad anatomy, mutated hand, error, missing finger, cropped, worse quality, bad quality, lowres, floating limbs, bad hands, anatomical nonsense"
|
| 43 |
-
hidden_cn_booster_text = ",loraeyes漂亮的脸,小胸,贫乳,a罩杯"
|
| 44 |
-
hidden_cn_negative = "大胸, ,, !, 。, ;,巨乳,性感,脏,d罩杯,e罩杯,g罩杯,骚,骚气,badhandv4, ng_deepnegative_v1_75t"
|
| 45 |
-
|
| 46 |
-
def translate(prompt):
|
| 47 |
-
trans_text = prompt
|
| 48 |
-
translated = model.generate(**tokenizer(trans_text, return_tensors="pt", padding=True))
|
| 49 |
-
tgt_text = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]
|
| 50 |
-
tgt_text = ''.join(tgt_text)[:-1]
|
| 51 |
-
return tgt_text
|
| 52 |
-
|
| 53 |
-
hed = HEDdetector.from_pretrained('lllyasviel/ControlNet')
|
| 54 |
-
|
| 55 |
-
controlnet_scribble = ControlNetModel.from_pretrained(
|
| 56 |
-
"lllyasviel/sd-controlnet-scribble", torch_dtype=torch.float16, safety_checker=None, requires_safety_checker=False, )
|
| 57 |
-
|
| 58 |
-
pipe_scribble = StableDiffusionControlNetPipeline.from_single_file(
|
| 59 |
-
"https://huggingface.co/shellypeng/anime-god/blob/main/animeGod_v10.safetensors", controlnet=controlnet_scribble, safety_checker=None, requires_safety_checker=False,
|
| 60 |
-
torch_dtype=torch.float16,
|
| 61 |
-
)
|
| 62 |
-
|
| 63 |
-
# pipe.load_lora_weights("shellypeng/detail-tweaker")
|
| 64 |
-
# pipe.load_lora_weights("shellypeng/midjourney-anime")
|
| 65 |
-
|
| 66 |
-
# pipe.load_lora_weights("shellypeng/animetarot")
|
| 67 |
-
# pipe.load_lora_weights("shellypeng/anime-stickers-v3")
|
| 68 |
-
# pipe.load_lora_weights("shellypeng/anime-magazine")
|
| 69 |
-
|
| 70 |
-
# pipe_img2img.load_lora_weights("yenojunie/slit-pupils")
|
| 71 |
-
|
| 72 |
-
# pipe_scribble.load_lora_weights("shellypeng/detail-tweaker")
|
| 73 |
-
# pipe_scribble.fuse_lora(lora_scale=0.1)
|
| 74 |
-
pipe_scribble.load_lora_weights("shellypeng/lora-eyes")
|
| 75 |
-
pipe_scribble.fuse_lora(lora_scale=0.1)
|
| 76 |
-
# pipe_scribble.load_lora_weights("shellypeng/beautiful-eyes")
|
| 77 |
-
# pipe_scribble.fuse_lora(lora_scale=0.1)
|
| 78 |
-
|
| 79 |
-
pipe_scribble.load_textual_inversion("shellypeng/bad-prompt")
|
| 80 |
-
pipe_scribble.load_textual_inversion("shellypeng/badhandv4")
|
| 81 |
-
# pipe.load_textual_inversion("shellypeng/easynegative")
|
| 82 |
-
pipe_scribble.load_textual_inversion("shellypeng/deepnegative")
|
| 83 |
-
pipe_scribble.load_textual_inversion("shellypeng/verybadimagenegative")
|
| 84 |
-
pipe_scribble.scheduler = DPMSolverMultistepScheduler.from_config(pipe_scribble.scheduler.config, use_karras_sigmas=True)
|
| 85 |
-
# pipe.enable_model_cpu_offload()
|
| 86 |
-
pipe_scribble.safety_checker = None
|
| 87 |
-
pipe_scribble.requires_safety_checker = False
|
| 88 |
-
pipe_scribble.to(device)
|
| 89 |
-
|
| 90 |
-
def scribble_to_image(text, neg_prompt_box, input_img):
|
| 91 |
-
"""
|
| 92 |
-
pass the sd model and do scribble to image
|
| 93 |
-
include Adetailer, detail tweaker lora, prompt backend include: beautiful eyes, beautiful face, beautiful hand, (maybe infer from user's prompt for gesture and facial
|
| 94 |
-
expression to improve hand)
|
| 95 |
-
"""
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
# if auto detect detects chinese => auto turn on chinese prompting checkbox
|
| 100 |
-
# change param "bag" below to text, image param below to input_img
|
| 101 |
-
input_img = Image.fromarray(input_img)
|
| 102 |
-
input_img = hed(input_img, scribble=True)
|
| 103 |
-
input_img = load_image(input_img)
|
| 104 |
-
# global prompt
|
| 105 |
-
lang_check_label = pipe(text, top_k=1, truncation=True)[0]['label']
|
| 106 |
-
lang_check_score = pipe(text, top_k=1, truncation=True)[0]['score']
|
| 107 |
-
if lang_check_label == 'zh' and lang_check_score >= 0.85:
|
| 108 |
-
text = translate(text)
|
| 109 |
-
compel_proc = Compel(tokenizer=pipe_scribble.tokenizer, text_encoder=pipe_scribble.text_encoder)
|
| 110 |
-
prompt = text + hidden_booster_text
|
| 111 |
-
prompt_embeds = compel_proc(prompt)
|
| 112 |
-
negative_prompt = neg_prompt_box + hidden_negative
|
| 113 |
-
negative_prompt_embeds = compel_proc(negative_prompt)
|
| 114 |
-
|
| 115 |
-
res_image0 = pipe_scribble(image=input_img, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 116 |
-
res_image1 = pipe_scribble(image=input_img, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 117 |
-
res_image2 = pipe_scribble(image=input_img, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 118 |
-
res_image3 = pipe_scribble(image=input_img, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 119 |
-
|
| 120 |
-
return res_image0, res_image1, res_image2, res_image3
|
| 121 |
-
|
| 122 |
-
def real_img2img_to_anime(text, neg_prompt_box, input_img):
|
| 123 |
-
"""
|
| 124 |
-
pass the sd model and do scribble to image
|
| 125 |
-
include Adetailer, detail tweaker lora, prompt backend include: beautiful eyes, beautiful face, beautiful hand, (maybe infer from user's prompt for gesture and facial
|
| 126 |
-
expression to improve hand)
|
| 127 |
-
"""
|
| 128 |
-
input_img = Image.fromarray(input_img)
|
| 129 |
-
input_img = load_image(input_img)
|
| 130 |
-
lang_check_label = pipe(text, top_k=1, truncation=True)[0]['label']
|
| 131 |
-
lang_check_score = pipe(text, top_k=1, truncation=True)[0]['score']
|
| 132 |
-
if lang_check_label == 'zh' and lang_check_score >= 0.85:
|
| 133 |
-
text = translate(text)
|
| 134 |
-
|
| 135 |
-
compel_proc = Compel(tokenizer=pipe_scribble.tokenizer, text_encoder=pipe_scribble.text_encoder)
|
| 136 |
-
prompt = text + hidden_booster_text
|
| 137 |
-
prompt_embeds = compel_proc(prompt)
|
| 138 |
-
|
| 139 |
-
negative_prompt = neg_prompt_box + hidden_negative
|
| 140 |
-
negative_prompt_embeds = compel_proc(negative_prompt)
|
| 141 |
-
# input_img = depth_estimator(input_img)['depth']
|
| 142 |
-
res_image0 = pipe_img2img(image=input_img, strength=0.6, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 143 |
-
res_image1 = pipe_img2img(image=input_img, strength=0.6, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 144 |
-
res_image2 = pipe_img2img(image=input_img, strength=0.6, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 145 |
-
res_image3 = pipe_img2img(image=input_img, strength=0.6, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_prompt_embeds, num_inference_steps=40).images[0]
|
| 146 |
-
|
| 147 |
-
return res_image0, res_image1, res_image2, res_image3
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
theme = gr.themes.Soft(
|
| 151 |
-
primary_hue="orange",
|
| 152 |
-
secondary_hue="orange",
|
| 153 |
-
).set(
|
| 154 |
-
block_background_fill='*primary_50'
|
| 155 |
-
)
|
| 156 |
-
|
| 157 |
-
# %cd /content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui
|
| 158 |
-
|
| 159 |
-
pipe_img2img = StableDiffusionImg2ImgPipeline.from_single_file("https://huggingface.co/shellypeng/anime-god/blob/main/animeGod_v10.safetensors",
|
| 160 |
-
torch_dtype=torch.float16, safety_checker=None, requires_safety_checker=False)
|
| 161 |
-
|
| 162 |
-
# pipe_img2img.load_lora_weights("shellypeng/detail-tweaker")
|
| 163 |
-
# pipe_img2img.fuse_lora(lora_scale=0.1)
|
| 164 |
-
pipe_img2img.load_lora_weights("shellypeng/lora-eyes")
|
| 165 |
-
pipe_img2img.fuse_lora(lora_scale=0.1)
|
| 166 |
-
# pipe_img2img.load_lora_weights("shellypeng/beautiful-eyes")
|
| 167 |
-
# pipe_img2img.fuse_lora(lora_scale=0.1)
|
| 168 |
-
|
| 169 |
-
pipe_img2img.load_textual_inversion("shellypeng/bad-prompt")
|
| 170 |
-
pipe_img2img.load_textual_inversion("shellypeng/badhandv4")
|
| 171 |
-
# pipe.load_textual_inversion("shellypeng/easynegative")
|
| 172 |
-
pipe_img2img.load_textual_inversion("shellypeng/deepnegative")
|
| 173 |
-
pipe_img2img.load_textual_inversion("shellypeng/verybadimagenegative")
|
| 174 |
-
pipe_img2img.scheduler = DPMSolverMultistepScheduler.from_config(pipe_img2img.scheduler.config, use_karras_sigmas=True)
|
| 175 |
-
# pipe.enable_model_cpu_offload()
|
| 176 |
-
pipe_img2img.safety_checker = None
|
| 177 |
-
pipe_img2img.requires_safety_checker = False
|
| 178 |
-
pipe_img2img.to(device)
|
| 179 |
-
|
| 180 |
-
# pipe_img2img.safety_checker = lambda images, **kwargs: (images, [False] * len(images))
|
| 181 |
-
|
| 182 |
-
# depth_estimator = pipeline('depth-estimation')
|
| 183 |
-
|
| 184 |
-
# controlnet_depth = ControlNetModel.from_pretrained(
|
| 185 |
-
# "lllyasviel/sd-controlnet-depth", torch_dtype=torch.float16
|
| 186 |
-
# )
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
# # models that worked well: anime god, pastel dream,
|
| 190 |
-
# # https://huggingface.co/shellypeng/featureless/tree/main
|
| 191 |
-
# pipe_depth = StableDiffusionControlNetPipeline.from_single_file(
|
| 192 |
-
# "https://huggingface.co/shellypeng/anime-god/blob/main/animeGod_v10.safetensors", controlnet=controlnet_depth,
|
| 193 |
-
# torch_dtype=torch.float16,
|
| 194 |
-
# )
|
| 195 |
-
# # pipe = StableDiffusionControlNetPipeline.from_pretrained("furusu/SSD-1B-anime",
|
| 196 |
-
# # torch_dtype=torch.float16
|
| 197 |
-
# # )
|
| 198 |
-
|
| 199 |
-
# pipe_depth.load_lora_weights("shellypeng/detail-tweaker")
|
| 200 |
-
# pipe_depth.fuse_lora(lora_scale=0.1)
|
| 201 |
-
# # pipe.load_lora_weights("shellypeng/stylized-3d")
|
| 202 |
-
# # pipe.load_lora_weights("shellypeng/midjourney-anime")
|
| 203 |
-
|
| 204 |
-
# # pipe.load_lora_weights("shellypeng/animetarot")
|
| 205 |
-
# # pipe.load_lora_weights("shellypeng/anime-stickers-v3")
|
| 206 |
-
# # pipe.load_lora_weights("shellypeng/anime-magazine")
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
# pipe_depth.load_textual_inversion("shellypeng/bad-prompt")
|
| 211 |
-
# pipe_depth.load_textual_inversion("shellypeng/badhandv4")
|
| 212 |
-
# # pipe.load_textual_inversion("shellypeng/easynegative")
|
| 213 |
-
# pipe_depth.load_textual_inversion("shellypeng/deepnegative")
|
| 214 |
-
# pipe_depth.load_textual_inversion("shellypeng/verybadimagenegative")
|
| 215 |
-
# pipe_depth.scheduler = DPMSolverMultistepScheduler.from_config(pipe_depth.scheduler.config, use_karras_sigmas=True)
|
| 216 |
-
# # pipe.enable_model_cpu_offload()
|
| 217 |
-
# def dummy(images, **kwargs):
|
| 218 |
-
# return images, False
|
| 219 |
-
# pipe_depth.safety_checker = lambda images, **kwargs: (images, [False] * len(images))
|
| 220 |
-
# pipe_depth.to(device)
|
| 221 |
-
# # pipe.load_lora_weights("shellypeng/detail-tweaker", weight_name="add_detail.safetensors")
|
| 222 |
-
|
| 223 |
-
# # load textual inversion negative embeddings!!!: pipe.load_textual_inversion("sd-concepts-library/cat-toy")
|
| 224 |
-
|
| 225 |
-
# def real_to_anime(text, input_img):
|
| 226 |
-
# """
|
| 227 |
-
# pass the sd model and do scribble to image
|
| 228 |
-
# include Adetailer, detail tweaker lora, prompt backend include: beautiful eyes, beautiful face, beautiful hand, (maybe infer from user's prompt for gesture and facial
|
| 229 |
-
# expression to improve hand)
|
| 230 |
-
# """
|
| 231 |
-
# input_img = Image.fromarray(input_img)
|
| 232 |
-
# input_img = load_image(input_img)
|
| 233 |
-
# input_img = depth_estimator(input_img)['depth']
|
| 234 |
-
# res_image0 = pipe_depth(prompt, input_img, negative_prompt=hidden_negative, num_inference_steps=40).images[0]
|
| 235 |
-
# res_image1 = pipe_depth(prompt, input_img, negative_prompt=hidden_negative, num_inference_steps=40).images[0]
|
| 236 |
-
# res_image2 = pipe_depth(prompt, input_img, negative_prompt=hidden_negative, num_inference_steps=40).images[0]
|
| 237 |
-
# res_image3 = pipe_depth(prompt, input_img, negative_prompt=hidden_negative, num_inference_steps=40).images[0]
|
| 238 |
-
|
| 239 |
-
# return res_image0, res_image1, res_image2, res_image3
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
# theme = gr.themes.Soft(
|
| 243 |
-
# primary_hue="orange",
|
| 244 |
-
# secondary_hue="orange",
|
| 245 |
-
# ).set(
|
| 246 |
-
# block_background_fill='*primary_50'
|
| 247 |
-
# )
|
| 248 |
-
|
| 249 |
-
def zh_prompt_info(text, neg_text, chinese_check):
|
| 250 |
-
can_raise_info = ""
|
| 251 |
-
lang_check_label = pipe(text, top_k=1, truncation=True)[0]['label']
|
| 252 |
-
lang_check_score = pipe(text, top_k=1, truncation=True)[0]['score']
|
| 253 |
-
neg_lang_check_label = pipe(neg_text, top_k=1, truncation=True)[0]['label']
|
| 254 |
-
neg_lang_check_score = pipe(neg_text, top_k=1, truncation=True)[0]['score']
|
| 255 |
-
print(lang_check_label)
|
| 256 |
-
if lang_check_label == 'zh' and lang_check_score >= 0.85:
|
| 257 |
-
if not chinese_check:
|
| 258 |
-
chinese_check = True
|
| 259 |
-
can_raise_info = "zh"
|
| 260 |
-
if neg_lang_check_label == 'en' and neg_lang_check_score >= 0.85:
|
| 261 |
-
can_raise_info = "invalid"
|
| 262 |
-
return True, can_raise_info
|
| 263 |
-
elif lang_check_label == 'en' and lang_check_score >= 0.85:
|
| 264 |
-
if chinese_check:
|
| 265 |
-
chinese_check = False
|
| 266 |
-
can_raise_info = "en"
|
| 267 |
-
if neg_lang_check_label == 'zh' and neg_lang_check_score >= 0.85:
|
| 268 |
-
can_raise_info = "invalid"
|
| 269 |
-
return False, can_raise_info
|
| 270 |
-
return chinese_check, can_raise_info
|
| 271 |
-
def mult_thread_img2img(prompt_box, neg_prompt_box, image_box):
|
| 272 |
-
with concurrent.futures.ThreadPoolExecutor(max_workers=12000) as executor:
|
| 273 |
-
future = executor.submit(real_img2img_to_anime, prompt_box, neg_prompt_box, image_box)
|
| 274 |
-
image1, image2, image3, image4 = future.result()
|
| 275 |
-
return image1, image2, image3, image4
|
| 276 |
-
def mult_thread_scribble(prompt_box, neg_prompt_box, image_box):
|
| 277 |
-
with concurrent.futures.ThreadPoolExecutor(max_workers=12000) as executor:
|
| 278 |
-
future = executor.submit(scribble_to_image, prompt_box, neg_prompt_box, image_box)
|
| 279 |
-
image1, image2, image3, image4 = future.result()
|
| 280 |
-
return image1, image2, image3, image4
|
| 281 |
-
def mult_thread_lang_class(prompt_box, neg_prompt_box, chinese_check):
|
| 282 |
-
|
| 283 |
-
with concurrent.futures.ThreadPoolExecutor(max_workers=12000) as executor:
|
| 284 |
-
future = executor.submit(zh_prompt_info, prompt_box, neg_prompt_box, chinese_check)
|
| 285 |
-
chinese_check, can_raise_info = future.result()
|
| 286 |
-
if can_raise_info == "zh":
|
| 287 |
-
gr.Info("Chinese Language Detected, Switching to Chinese Prompt Mode")
|
| 288 |
-
elif can_raise_info == "en":
|
| 289 |
-
gr.Info("English Language Detected, Disabling Chinese Prompt Mode")
|
| 290 |
-
return chinese_check
|
| 291 |
-
|
| 292 |
-
with gr.Blocks(theme=theme, css="footer {visibility: hidden}", title="ShellAI Apps") as iface:
|
| 293 |
-
with gr.Tab("Animefier"):
|
| 294 |
-
with gr.Row(equal_height=True):
|
| 295 |
-
with gr.Column():
|
| 296 |
-
with gr.Row(equal_height=True):
|
| 297 |
-
with gr.Column(scale=4):
|
| 298 |
-
prompt_box = gr.Textbox(label="Prompt", placeholder="Enter a prompt", lines=3)
|
| 299 |
-
neg_prompt_box = gr.Textbox(label="Negative Prompt", placeholder="Enter a negative prompt(things you don't want to include in the generated image)", lines=3)
|
| 300 |
-
with gr.Row(equal_height=True):
|
| 301 |
-
chinese_check = gr.Checkbox(label="Chinese Prompt Mode", info="Click here to enable Chinese Prompting(点此触发中文提示词输入)")
|
| 302 |
-
|
| 303 |
-
image_box = gr.Image(label="Input Image", height=350)
|
| 304 |
-
gen_btn = gr.Button(value="Generate")
|
| 305 |
-
|
| 306 |
-
with gr.Row(equal_height=True):
|
| 307 |
-
global image1
|
| 308 |
-
global image2
|
| 309 |
-
global image3
|
| 310 |
-
global image4
|
| 311 |
-
image1 = gr.Image(label="Result 1")
|
| 312 |
-
image2 = gr.Image(label="Result 2")
|
| 313 |
-
image3 = gr.Image(label="Result 3")
|
| 314 |
-
image4 = gr.Image(label="Result 4")
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
gr.on(triggers=[prompt_box.submit, gen_btn.click],fn=mult_thread_lang_class, inputs=[prompt_box, neg_prompt_box, chinese_check], outputs=[chinese_check], show_progress=False)
|
| 318 |
-
gr.on(triggers=[prompt_box.submit, gen_btn.click],fn=mult_thread_img2img, inputs=[prompt_box, neg_prompt_box, image_box], outputs=[image1, image2, image3, image4])
|
| 319 |
-
|
| 320 |
-
with gr.Tab("AniSketch"):
|
| 321 |
-
with gr.Row(equal_height=True):
|
| 322 |
-
with gr.Column():
|
| 323 |
-
with gr.Row(equal_height=True):
|
| 324 |
-
with gr.Column(scale=4):
|
| 325 |
-
prompt_box = gr.Textbox(label="Prompt", placeholder="Enter a prompt", lines=3)
|
| 326 |
-
neg_prompt_box = gr.Textbox(label="Negative Prompt", placeholder="Enter a negative prompt(things you don't want to include in the generated image)", lines=3)
|
| 327 |
-
with gr.Row(equal_height=True):
|
| 328 |
-
chinese_check = gr.Checkbox(label="Chinese Prompt Mode", info="Click here to enable Chinese Prompting(点此触发中文提示词输入)")
|
| 329 |
-
|
| 330 |
-
image_box = gr.Image(label="Input Image", height=350)
|
| 331 |
-
gen_btn = gr.Button(value="Generate")
|
| 332 |
-
with gr.Row(equal_height=True):
|
| 333 |
-
image1 = gr.Image(label="Result 1")
|
| 334 |
-
image2 = gr.Image(label="Result 2")
|
| 335 |
-
image3 = gr.Image(label="Result 3")
|
| 336 |
-
image4 = gr.Image(label="Result 4")
|
| 337 |
|
| 338 |
-
gr.on(triggers=[prompt_box.submit, gen_btn.click],fn=mult_thread_lang_class, inputs=[prompt_box, neg_prompt_box, chinese_check], outputs=[chinese_check], show_progress=False)
|
| 339 |
-
gr.on(triggers=[prompt_box.submit, gen_btn.click],fn=mult_thread_scribble, inputs=[prompt_box, neg_prompt_box, image_box], outputs=[image1, image2, image3, image4])
|
| 340 |
|
|
|
|
| 341 |
|
| 342 |
-
|
| 343 |
-
iface.dependencies[0]["show_progress"] = "hidden"
|
| 344 |
-
iface.launch(debug=True, share=True)
|
|
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Unt24314212442itled0.ipynb
|
| 3 |
|
| 4 |
Automatically generated by Colaboratory.
|
| 5 |
|
| 6 |
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1ESP90X7oIWvzEaEYUbh2Lp05cgpXSnZ8
|
| 8 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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