Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -62,17 +62,11 @@ class Prodia:
|
|
62 |
|
63 |
|
64 |
def image_to_base64(image_path):
|
65 |
-
# Open the image with PIL
|
66 |
with Image.open(image_path) as image:
|
67 |
-
# Convert the image to bytes
|
68 |
buffered = BytesIO()
|
69 |
-
image.save(buffered, format="PNG")
|
70 |
-
|
71 |
-
# Encode the bytes to base64
|
72 |
img_str = base64.b64encode(buffered.getvalue())
|
73 |
-
|
74 |
-
return img_str.decode('utf-8') # Convert bytes to string
|
75 |
-
|
76 |
|
77 |
|
78 |
prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
|
@@ -101,50 +95,35 @@ css = """
|
|
101 |
"""
|
102 |
|
103 |
with gr.Blocks(css=css) as demo:
|
104 |
-
|
105 |
-
|
106 |
with gr.Row():
|
107 |
-
with gr.Column(
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
prompt = gr.Textbox("space warrior, beautiful, female, ultrarealistic, soft lighting, 8k", placeholder="Prompt", show_label=False, lines=3)
|
117 |
-
negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=False, lines=3, value="3d, cartoon, anime, (deformed eyes, nose, ears, nose), bad anatomy, ugly")
|
118 |
-
with gr.Column():
|
119 |
-
text_button = gr.Button("Generate", variant='primary', elem_id="generate")
|
120 |
-
|
121 |
-
with gr.Row():
|
122 |
-
with gr.Column(scale=3):
|
123 |
-
with gr.Tab("Generation"):
|
124 |
-
with gr.Row():
|
125 |
-
with gr.Column(scale=1):
|
126 |
-
sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method", choices=prodia_client.list_samplers())
|
127 |
-
|
128 |
-
with gr.Column(scale=1):
|
129 |
-
steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=25, value=20, step=1)
|
130 |
-
|
131 |
-
with gr.Row():
|
132 |
-
with gr.Column(scale=1):
|
133 |
-
width = gr.Slider(label="Width", minimum=512, maximum=1536, value=1024, step=8)
|
134 |
-
height = gr.Slider(label="Height", minimum=512, maximum=1536, value=1024, step=8)
|
135 |
-
gr.Markdown(elem_id="resolution", value="*Resolution Maximum: 1MP (1048576 px)*")
|
136 |
-
|
137 |
-
with gr.Column(scale=1):
|
138 |
-
batch_size = gr.Slider(label="Batch Size", maximum=1, value=1)
|
139 |
-
batch_count = gr.Slider(label="Batch Count", maximum=1, value=1)
|
140 |
-
|
141 |
-
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
|
142 |
-
seed = gr.Number(label="Seed", value=-1)
|
143 |
-
|
144 |
|
145 |
-
|
146 |
-
|
147 |
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
demo.queue(concurrency_count=24, max_size=32, api_open=False).launch(max_threads=128)
|
|
|
62 |
|
63 |
|
64 |
def image_to_base64(image_path):
|
|
|
65 |
with Image.open(image_path) as image:
|
|
|
66 |
buffered = BytesIO()
|
67 |
+
image.save(buffered, format="PNG")
|
|
|
|
|
68 |
img_str = base64.b64encode(buffered.getvalue())
|
69 |
+
return img_str.decode('utf-8')
|
|
|
|
|
70 |
|
71 |
|
72 |
prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
|
|
|
95 |
"""
|
96 |
|
97 |
with gr.Blocks(css=css) as demo:
|
|
|
|
|
98 |
with gr.Row():
|
99 |
+
with gr.Column():
|
100 |
+
gr.Markdown("# Disney Pixar AI Poster Generator")
|
101 |
+
gr.Markdown("Enter your prompt and adjust the settings to generate a Disney Pixar style AI poster.")
|
102 |
+
|
103 |
+
with gr.Row():
|
104 |
+
with gr.Column(scale=2):
|
105 |
+
prompt = gr.Textbox("space warrior, beautiful, female, ultrarealistic, soft lighting, 8k", placeholder="Prompt", show_label=False, lines=3)
|
106 |
+
negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=False, lines=3, value="3d, cartoon, anime, (deformed eyes, nose, ears, nose), bad anatomy, ugly")
|
107 |
+
text_button = gr.Button("Generate", variant='primary', elem_id="generate")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
+
with gr.Column(scale=4):
|
110 |
+
image_output = gr.Image(value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png", label="Generated Image")
|
111 |
|
112 |
+
with gr.Row():
|
113 |
+
with gr.Column(scale=2):
|
114 |
+
model = gr.Dropdown(interactive=True, value="sd_xl_base_1.0.safetensors [be9edd61]", show_label=True, label="Stable Diffusion Checkpoint", choices=prodia_client.list_models())
|
115 |
+
sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method", choices=prodia_client.list_samplers())
|
116 |
+
steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=25, value=20, step=1)
|
117 |
+
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
|
118 |
+
seed = gr.Number(label="Seed", value=-1)
|
119 |
+
|
120 |
+
with gr.Column(scale=2):
|
121 |
+
width = gr.Slider(label="Width", minimum=512, maximum=1536, value=1024, step=8)
|
122 |
+
height = gr.Slider(label="Height", minimum=512, maximum=1536, value=1024, step=8)
|
123 |
+
batch_size = gr.Slider(label="Batch Size", maximum=1, value=1)
|
124 |
+
batch_count = gr.Slider(label="Batch Count", maximum=1, value=1)
|
125 |
+
gr.Markdown("*Resolution Maximum: 1MP (1048576 px)*")
|
126 |
+
|
127 |
+
text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
|
128 |
|
129 |
demo.queue(concurrency_count=24, max_size=32, api_open=False).launch(max_threads=128)
|