Spaces:
Runtime error
Runtime error
update
Browse files- .gitignore +2 -1
- .pylintrc +3 -1
- app.py +42 -17
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
|
|
|
|
1 |
+
outputs
|
2 |
+
flagged
|
.pylintrc
CHANGED
@@ -1,2 +1,4 @@
|
|
1 |
[pylint.messages_control]
|
2 |
-
disable=W0612,W0621,C0411,W0611,C0114,C0116,W1514,C0103,W0718,W0602
|
|
|
|
|
|
1 |
[pylint.messages_control]
|
2 |
+
disable=W0612,W0621,C0411,W0611,C0114,C0116,W1514,C0103,W0718,W0602,C0301
|
3 |
+
|
4 |
+
# Line too long (C0301)
|
app.py
CHANGED
@@ -13,11 +13,11 @@ initial_height = 512
|
|
13 |
|
14 |
params = {
|
15 |
"enable_SD_api": True,
|
16 |
-
"address": "https://
|
17 |
"save_img": True,
|
18 |
-
"SD_model": "
|
19 |
-
"prompt_prefix": "
|
20 |
-
"negative_prompt": "
|
21 |
"width": initial_width,
|
22 |
"height": initial_height,
|
23 |
"restore_faces": False,
|
@@ -41,9 +41,15 @@ def get_SD_pictures(description):
|
|
41 |
"negative_prompt": params["negative_prompt"],
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
r = response.json()
|
49 |
|
@@ -73,21 +79,38 @@ def get_SD_pictures(description):
|
|
73 |
return visible_result
|
74 |
|
75 |
|
76 |
-
def display_image(description: str,
|
77 |
-
if
|
78 |
description += " <lora:Kashif_v1:0.9>"
|
79 |
-
|
80 |
description += " <lora:DanielHo_v1:0.9>"
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
else:
|
86 |
params["width"] = initial_width
|
87 |
params["height"] = initial_height
|
|
|
88 |
|
89 |
visible_result = get_SD_pictures(description)
|
90 |
-
|
|
|
|
|
91 |
image_data = base64.b64decode(visible_result.split(",", 1)[1])
|
92 |
image = Image.open(io.BytesIO(image_data))
|
93 |
return image
|
@@ -95,8 +118,10 @@ def display_image(description: str, kashif: bool, daniel_ho: bool) -> gr.Image:
|
|
95 |
|
96 |
inputs = [
|
97 |
gr.inputs.Textbox(lines=2, label="Enter image description"),
|
98 |
-
gr.inputs.
|
99 |
-
|
|
|
|
|
100 |
]
|
101 |
|
102 |
outputs = gr.outputs.Image(type="pil", label="Generated Image")
|
|
|
13 |
|
14 |
params = {
|
15 |
"enable_SD_api": True,
|
16 |
+
"address": "https://253f-2001-d08-e3-5197-8959-3944-7869-3df9.ngrok-free.app",
|
17 |
"save_img": True,
|
18 |
+
"SD_model": "Chilloutmix-Ni-prune-fp32-fix.safetensors",
|
19 |
+
"prompt_prefix": "detailed portrait of a asian man in black jacket, Futuristic sci-fi fashion, fine details, realistic shaded, fine-face, pretty face cyberpunk, neotokyo, synthwave, aesthetics, futuristic, low-emission-neon, (blade runner movie scene)",
|
20 |
+
"negative_prompt": "jpeg artifacts, low quality, lowres, 3d, render, doll, plastic, blur, haze, monochrome, b&w, text, (ugly:1.2), unclear eyes, no arms, bad anatomy, cropped, censoring, asymmetric eyes, bad anatomy, bad proportions, cropped, cross-eyed, deformed, extra arms, extra fingers, extra limbs, fused fingers, malformed, mangled hands, misshapen body, missing arms, missing fingers, missing hands, missing legs, poorly drawn, tentacle finger, too many arms, too many fingers, watermark, logo, text, letters, signature, username, words, blurry, cropped",
|
21 |
"width": initial_width,
|
22 |
"height": initial_height,
|
23 |
"restore_faces": False,
|
|
|
41 |
"negative_prompt": params["negative_prompt"],
|
42 |
}
|
43 |
|
44 |
+
try:
|
45 |
+
response = requests.post(
|
46 |
+
url=f'{params["address"]}/sdapi/v1/txt2img', json=payload, timeout=100
|
47 |
+
)
|
48 |
+
response.raise_for_status() # Raises stored HTTPError, if one occurred
|
49 |
+
except requests.exceptions.HTTPError as http_err:
|
50 |
+
return f"HTTP error occurred: {http_err}"
|
51 |
+
except Exception as err:
|
52 |
+
return f"An error occurred: {err}"
|
53 |
|
54 |
r = response.json()
|
55 |
|
|
|
79 |
return visible_result
|
80 |
|
81 |
|
82 |
+
def display_image(description: str, artist: str) -> gr.Image:
|
83 |
+
if artist == "Kashif":
|
84 |
description += " <lora:Kashif_v1:0.9>"
|
85 |
+
elif artist == "Daniel Ho":
|
86 |
description += " <lora:DanielHo_v1:0.9>"
|
87 |
+
elif artist == "Adrian":
|
88 |
+
description += " <lora:AdrianSeowV1:0.9>"
|
89 |
+
elif artist == "Tony":
|
90 |
+
description += " <lora:TonyYap4:0.9>"
|
91 |
+
elif artist == "Kevin":
|
92 |
+
description += " <lora:KevinLowV1:0.9>"
|
93 |
+
elif artist == "Aaron":
|
94 |
+
description += " <lora:AaronSiowV1:0.9>"
|
95 |
+
|
96 |
+
if artist == "none":
|
97 |
+
artist = False
|
98 |
+
|
99 |
+
if artist:
|
100 |
+
params["width"] = 768
|
101 |
+
params["height"] = 768
|
102 |
+
params[
|
103 |
+
"prompt_prefix"
|
104 |
+
] = "detailed portrait of a asian man in black jacket, Futuristic sci-fi fashion, fine details, realistic shaded, fine-face, pretty face cyberpunk, neotokyo, synthwave, aesthetics, futuristic, low-emission-neon, (blade runner movie scene)"
|
105 |
else:
|
106 |
params["width"] = initial_width
|
107 |
params["height"] = initial_height
|
108 |
+
params["prompt_prefix"] = "4k"
|
109 |
|
110 |
visible_result = get_SD_pictures(description)
|
111 |
+
if "error occurred" in visible_result:
|
112 |
+
return visible_result
|
113 |
+
|
114 |
image_data = base64.b64decode(visible_result.split(",", 1)[1])
|
115 |
image = Image.open(io.BytesIO(image_data))
|
116 |
return image
|
|
|
118 |
|
119 |
inputs = [
|
120 |
gr.inputs.Textbox(lines=2, label="Enter image description"),
|
121 |
+
gr.inputs.Radio(
|
122 |
+
["Kashif", "Daniel Ho", "Adrian", "Tony", "Kevin", "Aaron", "none"],
|
123 |
+
label="Artist",
|
124 |
+
),
|
125 |
]
|
126 |
|
127 |
outputs = gr.outputs.Image(type="pil", label="Generated Image")
|