Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,16 +11,19 @@ from PIL import Image, ImageFilter, ImageOps
|
|
| 11 |
from huggingface_hub import login, hf_hub_download
|
| 12 |
import os
|
| 13 |
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
| 15 |
if "HF_TOKEN" in os.environ:
|
| 16 |
login(os.environ["HF_TOKEN"])
|
| 17 |
else:
|
| 18 |
raise ValueError("HF_TOKEN not found in environment variables. Please set it in Space settings.")
|
| 19 |
|
| 20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 21 |
-
|
| 22 |
-
repo_id = "DreamingOracle/Quagmaform_alpha-1"
|
| 23 |
-
filename = "DPS_Quagmaform_Alpha1.safetensors"
|
| 24 |
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 25 |
if torch.cuda.is_available():
|
| 26 |
torch_dtype = torch.float16
|
|
@@ -76,7 +79,7 @@ def infer(
|
|
| 76 |
# 1) Pad bbox so inpaint has surrounding context
|
| 77 |
w = max(1, x2 - x1)
|
| 78 |
h = max(1, y2 - y1)
|
| 79 |
-
pad = int(max(10, 0.18 * max(w, h))) # ~18% padding, tweak if desired
|
| 80 |
x1p = max(0, x1 - pad)
|
| 81 |
y1p = max(0, y1 - pad)
|
| 82 |
x2p = min(image.width, x2 + pad)
|
|
@@ -130,11 +133,14 @@ def infer(
|
|
| 130 |
examples = [
|
| 131 |
"photorealistic portrait of a young woman, cinematic rim lighting, soft golden hour backlight, detailed skin pores, realistic eyelashes, 85mm lens, shallow depth of field, ultra-detailed, high dynamic range, film grain, detailed, 8k",
|
| 132 |
"head helmet portrait of a futuristic armored soldier, worn brushed metal armor with neon blue accents, realistic cloth under-armor, weathering and scratches, volumetric rim light, cinematic pose, high detail, photoreal",
|
| 133 |
-
"
|
| 134 |
|
| 135 |
css = """#col-container { margin: 0 auto; max-width: 640px;}"""
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
with gr.Column(elem_id="col-container"):
|
| 139 |
gr.Markdown(" # DPS-Quagmaform AI txt2img")
|
| 140 |
with gr.Row():
|
|
|
|
| 11 |
from huggingface_hub import login, hf_hub_download
|
| 12 |
import os
|
| 13 |
|
| 14 |
+
# Add this import for theming
|
| 15 |
+
from gradio import themes
|
| 16 |
+
|
| 17 |
+
|
| 18 |
if "HF_TOKEN" in os.environ:
|
| 19 |
login(os.environ["HF_TOKEN"])
|
| 20 |
else:
|
| 21 |
raise ValueError("HF_TOKEN not found in environment variables. Please set it in Space settings.")
|
| 22 |
|
| 23 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 24 |
+
|
| 25 |
+
repo_id = "DreamingOracle/Quagmaform_alpha-1"
|
| 26 |
+
filename = "DPS_Quagmaform_Alpha1.safetensors"
|
| 27 |
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 28 |
if torch.cuda.is_available():
|
| 29 |
torch_dtype = torch.float16
|
|
|
|
| 79 |
# 1) Pad bbox so inpaint has surrounding context
|
| 80 |
w = max(1, x2 - x1)
|
| 81 |
h = max(1, y2 - y1)
|
| 82 |
+
pad = int(max(10, 0.18 * max(w, h))) # ~18% padding, tweak if desired to lower value for scenic panorama preservation
|
| 83 |
x1p = max(0, x1 - pad)
|
| 84 |
y1p = max(0, y1 - pad)
|
| 85 |
x2p = min(image.width, x2 + pad)
|
|
|
|
| 133 |
examples = [
|
| 134 |
"photorealistic portrait of a young woman, cinematic rim lighting, soft golden hour backlight, detailed skin pores, realistic eyelashes, 85mm lens, shallow depth of field, ultra-detailed, high dynamic range, film grain, detailed, 8k",
|
| 135 |
"head helmet portrait of a futuristic armored soldier, worn brushed metal armor with neon blue accents, realistic cloth under-armor, weathering and scratches, volumetric rim light, cinematic pose, high detail, photoreal",
|
| 136 |
+
"close up view of silver coins on a table",]
|
| 137 |
|
| 138 |
css = """#col-container { margin: 0 auto; max-width: 640px;}"""
|
| 139 |
|
| 140 |
+
# Create the custom purple theme
|
| 141 |
+
custom_theme = themes.Default(primary_hue="purple")
|
| 142 |
+
|
| 143 |
+
with gr.Blocks(css=css, theme=custom_theme) as demo:
|
| 144 |
with gr.Column(elem_id="col-container"):
|
| 145 |
gr.Markdown(" # DPS-Quagmaform AI txt2img")
|
| 146 |
with gr.Row():
|