Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,19 +6,19 @@ from style_template import styles
|
|
6 |
import base64
|
7 |
|
8 |
prodia = Prodia()
|
9 |
-
|
10 |
-
|
11 |
MAX_SEED = np.iinfo(np.int32).max
|
12 |
|
13 |
|
14 |
-
def generate_image(upload_images, prompt, negative_prompt,
|
15 |
error_if_no_img(prompt)
|
16 |
-
p, n = apply_style(style_name, prompt, negative_prompt)
|
17 |
|
18 |
job = prodia.create("/photomaker",
|
19 |
imageData=[file_to_base64(img) for img in upload_images],
|
20 |
-
prompt=
|
21 |
-
negative_prompt=
|
|
|
22 |
steps=steps,
|
23 |
strength=strength,
|
24 |
seed=seed if seed != 0 else None
|
@@ -45,11 +45,6 @@ def remove_back_to_files():
|
|
45 |
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
46 |
|
47 |
|
48 |
-
def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str, str]:
|
49 |
-
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
50 |
-
return p.replace("{prompt}", positive), n + ' ' + negative
|
51 |
-
|
52 |
-
|
53 |
def get_image_path_list(folder_name):
|
54 |
image_basename_list = os.listdir(folder_name)
|
55 |
image_path_list = sorted([os.path.join(folder_name, basename) for basename in image_basename_list])
|
@@ -68,13 +63,13 @@ def get_example():
|
|
68 |
[
|
69 |
get_image_path_list('./examples/scarletthead_woman'),
|
70 |
"instagram photo, portrait photo of a woman img, colorful, perfect face, natural skin, hard shadows, film grain",
|
71 |
-
|
72 |
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
73 |
],
|
74 |
[
|
75 |
get_image_path_list('./examples/newton_man'),
|
76 |
"sci-fi, closeup portrait photo of a man img wearing the sunglasses in Iron man suit, face, slim body, high quality, film grain",
|
77 |
-
|
78 |
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
79 |
],
|
80 |
]
|
@@ -104,7 +99,7 @@ with gr.Blocks(css=css) as demo:
|
|
104 |
prompt = gr.Textbox(label="Prompt",
|
105 |
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
106 |
placeholder="A photo of a [man/woman img]...")
|
107 |
-
style = gr.Dropdown(label="Style template", choices=
|
108 |
submit = gr.Button("Submit")
|
109 |
|
110 |
with gr.Accordion(open=False, label="Advanced Options"):
|
|
|
6 |
import base64
|
7 |
|
8 |
prodia = Prodia()
|
9 |
+
STYLE_PRESETS = [None, "3d-model", "analog-film", "anime", "cinematic", "comic-book", "digital-art", "enhance", "fantasy-art", "isometric", "line-art", "low-poly",
|
10 |
+
"neon-punk", "origami", "photographic", "pixel-art", "texture", "craft-clay"]
|
11 |
MAX_SEED = np.iinfo(np.int32).max
|
12 |
|
13 |
|
14 |
+
def generate_image(upload_images, prompt, negative_prompt, style_preset, steps, strength, seed, progress=gr.Progress(track_tqdm=True)):
|
15 |
error_if_no_img(prompt)
|
|
|
16 |
|
17 |
job = prodia.create("/photomaker",
|
18 |
imageData=[file_to_base64(img) for img in upload_images],
|
19 |
+
prompt=prompt,
|
20 |
+
negative_prompt=negative_prompt,
|
21 |
+
style_preset=style_preset,
|
22 |
steps=steps,
|
23 |
strength=strength,
|
24 |
seed=seed if seed != 0 else None
|
|
|
45 |
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
46 |
|
47 |
|
|
|
|
|
|
|
|
|
|
|
48 |
def get_image_path_list(folder_name):
|
49 |
image_basename_list = os.listdir(folder_name)
|
50 |
image_path_list = sorted([os.path.join(folder_name, basename) for basename in image_basename_list])
|
|
|
63 |
[
|
64 |
get_image_path_list('./examples/scarletthead_woman'),
|
65 |
"instagram photo, portrait photo of a woman img, colorful, perfect face, natural skin, hard shadows, film grain",
|
66 |
+
None,
|
67 |
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
68 |
],
|
69 |
[
|
70 |
get_image_path_list('./examples/newton_man'),
|
71 |
"sci-fi, closeup portrait photo of a man img wearing the sunglasses in Iron man suit, face, slim body, high quality, film grain",
|
72 |
+
None,
|
73 |
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
74 |
],
|
75 |
]
|
|
|
99 |
prompt = gr.Textbox(label="Prompt",
|
100 |
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
101 |
placeholder="A photo of a [man/woman img]...")
|
102 |
+
style = gr.Dropdown(label="Style template", choices=STYLE_PRESETS, value=None)
|
103 |
submit = gr.Button("Submit")
|
104 |
|
105 |
with gr.Accordion(open=False, label="Advanced Options"):
|