Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,30 +39,27 @@ qrcode_generator = qrcode.QRCode(
|
|
| 39 |
# Define available models
|
| 40 |
CONTROLNET_MODELS = {
|
| 41 |
"QR Code Monster": "monster-labs/control_v1p_sd15_qrcode_monster",
|
| 42 |
-
"QR Code": "DionTimmer/controlnet_qrcode",
|
| 43 |
# Add more ControlNet models here
|
| 44 |
}
|
| 45 |
|
| 46 |
DIFFUSION_MODELS = {
|
| 47 |
"Stable Diffusion v1.5": "ckpt/sd15",
|
| 48 |
-
"GhostMix
|
| 49 |
-
"Real-Dream": "
|
| 50 |
# Add more diffusion models here
|
| 51 |
}
|
| 52 |
|
| 53 |
def load_models(controlnet_model, diffusion_model):
|
| 54 |
-
hf_token = get_hf_token()
|
| 55 |
|
| 56 |
controlnet = ControlNetModel.from_pretrained(
|
| 57 |
CONTROLNET_MODELS[controlnet_model],
|
| 58 |
-
use_auth_token=hf_token,
|
| 59 |
torch_dtype=torch.float16
|
| 60 |
).to("cuda")
|
| 61 |
|
| 62 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 63 |
DIFFUSION_MODELS[diffusion_model],
|
| 64 |
controlnet=controlnet,
|
| 65 |
-
use_auth_token=hf_token,
|
| 66 |
torch_dtype=torch.float16,
|
| 67 |
safety_checker=None,
|
| 68 |
).to("cuda")
|
|
@@ -148,7 +145,7 @@ def invert_displayed_image(image):
|
|
| 148 |
return Image.fromarray(inverted)
|
| 149 |
return inverted
|
| 150 |
|
| 151 |
-
|
| 152 |
def inference(
|
| 153 |
qr_code_content: str,
|
| 154 |
prompt: str,
|
|
@@ -295,12 +292,13 @@ with gr.Blocks(theme='Hev832/Applio') as blocks:
|
|
| 295 |
prompt = gr.Textbox(
|
| 296 |
label="Artistic Prompt",
|
| 297 |
placeholder="Describe the style or theme for your QR code art",
|
|
|
|
| 298 |
info="Be specific and creative! This guides the AI in creating your unique QR code art.",
|
| 299 |
)
|
| 300 |
negative_prompt = gr.Textbox(
|
| 301 |
label="Elements to Avoid",
|
| 302 |
placeholder="Describe what you don't want in the image",
|
| 303 |
-
value="ugly, disfigured, low quality, blurry, nsfw",
|
| 304 |
info="List elements or styles you want to avoid in your QR code art.",
|
| 305 |
)
|
| 306 |
use_qr_code_as_init_image = gr.Checkbox(
|
|
@@ -531,5 +529,5 @@ with gr.Blocks(theme='Hev832/Applio') as blocks:
|
|
| 531 |
concurrency_limit=20
|
| 532 |
)
|
| 533 |
|
| 534 |
-
blocks.queue(max_size=20
|
| 535 |
-
blocks.launch(share=
|
|
|
|
| 39 |
# Define available models
|
| 40 |
CONTROLNET_MODELS = {
|
| 41 |
"QR Code Monster": "monster-labs/control_v1p_sd15_qrcode_monster",
|
| 42 |
+
"QR Code": "DionTimmer/controlnet_qrcode-control_v1p_sd15",
|
| 43 |
# Add more ControlNet models here
|
| 44 |
}
|
| 45 |
|
| 46 |
DIFFUSION_MODELS = {
|
| 47 |
"Stable Diffusion v1.5": "ckpt/sd15",
|
| 48 |
+
"GhostMix": "sinkinai/GhostMix-V2-BakedVae",
|
| 49 |
+
"Real-Dream": "stablediffusionapi/edge-of-realism",
|
| 50 |
# Add more diffusion models here
|
| 51 |
}
|
| 52 |
|
| 53 |
def load_models(controlnet_model, diffusion_model):
|
|
|
|
| 54 |
|
| 55 |
controlnet = ControlNetModel.from_pretrained(
|
| 56 |
CONTROLNET_MODELS[controlnet_model],
|
|
|
|
| 57 |
torch_dtype=torch.float16
|
| 58 |
).to("cuda")
|
| 59 |
|
| 60 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 61 |
DIFFUSION_MODELS[diffusion_model],
|
| 62 |
controlnet=controlnet,
|
|
|
|
| 63 |
torch_dtype=torch.float16,
|
| 64 |
safety_checker=None,
|
| 65 |
).to("cuda")
|
|
|
|
| 145 |
return Image.fromarray(inverted)
|
| 146 |
return inverted
|
| 147 |
|
| 148 |
+
#@spaces.GPU()
|
| 149 |
def inference(
|
| 150 |
qr_code_content: str,
|
| 151 |
prompt: str,
|
|
|
|
| 292 |
prompt = gr.Textbox(
|
| 293 |
label="Artistic Prompt",
|
| 294 |
placeholder="Describe the style or theme for your QR code art",
|
| 295 |
+
value="A high-resolution, photo-realistic minimalist rendering of Mount Fuji, depicted as a sharp, semi-realistic silhouette of a mountain range on the horizon. The mountain evokes strength and motion with clean, crisp lines and a sense of natural flow. The scene should feature detailed snow textures, subtle highlights on the mountain ridges, and a powerful yet serene atmosphere. The rendering should emphasize the strength of the mountain with a focus on clarity and precision in both texture and light. (Sharp outlines:1.5), (Photo-realistic:1.4), (Detailed textures:1.3), (Minimalist:1.3), (Semi-realistic:1.3), (Monochrome contrast:1.2), (Crisp detail:1.2), (Evoking strength:1.2), inspired by traditional Japanese woodblock prints, nature photography, and minimalist design principles.",
|
| 296 |
info="Be specific and creative! This guides the AI in creating your unique QR code art.",
|
| 297 |
)
|
| 298 |
negative_prompt = gr.Textbox(
|
| 299 |
label="Elements to Avoid",
|
| 300 |
placeholder="Describe what you don't want in the image",
|
| 301 |
+
value="ugly, disfigured, low quality, blurry, nsfw, bad_pictures, (bad_prompt_version2:0.8), EasyNegative, 3d, cartoon, anime, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), poorly drawn, distorted, overexposed, flat shading, bad proportions, deformed, pixelated, messy details, lack of contrast, unrealistic textures, bad anatomy, rough edges, low resolution, text artifacts.",
|
| 302 |
info="List elements or styles you want to avoid in your QR code art.",
|
| 303 |
)
|
| 304 |
use_qr_code_as_init_image = gr.Checkbox(
|
|
|
|
| 529 |
concurrency_limit=20
|
| 530 |
)
|
| 531 |
|
| 532 |
+
blocks.queue(max_size=20)
|
| 533 |
+
blocks.launch(share=True, show_api=True)
|