Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,23 +20,22 @@ MAX_IMAGE_SIZE = 1024
|
|
| 20 |
)
|
| 21 |
def infer(
|
| 22 |
prompt,
|
| 23 |
-
|
| 24 |
seed,
|
| 25 |
randomize_seed,
|
| 26 |
width,
|
| 27 |
height,
|
| 28 |
# Enhancement
|
| 29 |
-
enhance=
|
| 30 |
|
| 31 |
-
|
| 32 |
-
transparent=False, # Transparent background (default: False)
|
| 33 |
image=None, # Input image URL for img2img
|
| 34 |
|
| 35 |
# Privacy
|
| 36 |
private=False, # Private generation (default: False)
|
| 37 |
nologo=False, # Remove watermark (default: False)
|
| 38 |
nofeed=False, # Don't add to public feed (default: False)
|
| 39 |
-
|
| 40 |
|
| 41 |
|
| 42 |
):
|
|
@@ -58,7 +57,8 @@ def infer(
|
|
| 58 |
url = f"https://image.pollinations.ai/prompt/{quote(prompt)}"
|
| 59 |
# Customize the image size and model
|
| 60 |
params = {"width": width, "height": height, "model": "flux","seed":seed}
|
| 61 |
-
|
|
|
|
| 62 |
# Make the request
|
| 63 |
response = requests.get(url, params=params, timeout=60)
|
| 64 |
image_data = BytesIO(response.content)
|
|
@@ -70,7 +70,7 @@ def infer(
|
|
| 70 |
examples = [
|
| 71 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 72 |
"An astronaut riding a green horse",
|
| 73 |
-
"A delicious ceviche cheesecake slice"
|
| 74 |
]
|
| 75 |
|
| 76 |
css = """
|
|
@@ -98,12 +98,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 98 |
result = gr.Image(label="Result", show_label=False)
|
| 99 |
|
| 100 |
with gr.Accordion("Advanced Settings", open=False):
|
| 101 |
-
negative_prompt = gr.Text(
|
| 102 |
-
label="Negative prompt",
|
| 103 |
-
max_lines=1,
|
| 104 |
-
placeholder="Enter a negative prompt",
|
| 105 |
-
visible=False,
|
| 106 |
-
)
|
| 107 |
|
| 108 |
seed = gr.Slider(
|
| 109 |
label="Seed",
|
|
@@ -132,22 +126,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 132 |
value=1024, # Replace with defaults that work for your model
|
| 133 |
)
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
# step=0.1,
|
| 141 |
-
# value=0.0, # Replace with defaults that work for your model
|
| 142 |
-
# )
|
| 143 |
-
|
| 144 |
-
# num_inference_steps = gr.Slider(
|
| 145 |
-
# label="Number of inference steps",
|
| 146 |
-
# minimum=1,
|
| 147 |
-
# maximum=50,
|
| 148 |
-
# step=1,
|
| 149 |
-
# value=2, # Replace with defaults that work for your model
|
| 150 |
-
# )
|
| 151 |
|
| 152 |
gr.Examples(examples=examples, inputs=[prompt])
|
| 153 |
gr.on(
|
|
@@ -155,11 +138,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 155 |
fn=infer,
|
| 156 |
inputs=[
|
| 157 |
prompt,
|
| 158 |
-
negative_prompt,
|
| 159 |
seed,
|
| 160 |
randomize_seed,
|
| 161 |
width,
|
| 162 |
height,
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
],
|
| 165 |
outputs=[result, seed],
|
|
|
|
| 20 |
)
|
| 21 |
def infer(
|
| 22 |
prompt,
|
| 23 |
+
|
| 24 |
seed,
|
| 25 |
randomize_seed,
|
| 26 |
width,
|
| 27 |
height,
|
| 28 |
# Enhancement
|
| 29 |
+
enhance=False, # Auto-enhance prompt (default: False)
|
| 30 |
|
| 31 |
+
|
|
|
|
| 32 |
image=None, # Input image URL for img2img
|
| 33 |
|
| 34 |
# Privacy
|
| 35 |
private=False, # Private generation (default: False)
|
| 36 |
nologo=False, # Remove watermark (default: False)
|
| 37 |
nofeed=False, # Don't add to public feed (default: False)
|
| 38 |
+
|
| 39 |
|
| 40 |
|
| 41 |
):
|
|
|
|
| 57 |
url = f"https://image.pollinations.ai/prompt/{quote(prompt)}"
|
| 58 |
# Customize the image size and model
|
| 59 |
params = {"width": width, "height": height, "model": "flux","seed":seed}
|
| 60 |
+
if image is not None:
|
| 61 |
+
params["image"]=image
|
| 62 |
# Make the request
|
| 63 |
response = requests.get(url, params=params, timeout=60)
|
| 64 |
image_data = BytesIO(response.content)
|
|
|
|
| 70 |
examples = [
|
| 71 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 72 |
"An astronaut riding a green horse",
|
| 73 |
+
"A delicious ceviche cheesecake slice"
|
| 74 |
]
|
| 75 |
|
| 76 |
css = """
|
|
|
|
| 98 |
result = gr.Image(label="Result", show_label=False)
|
| 99 |
|
| 100 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
seed = gr.Slider(
|
| 103 |
label="Seed",
|
|
|
|
| 126 |
value=1024, # Replace with defaults that work for your model
|
| 127 |
)
|
| 128 |
|
| 129 |
+
with gr.Row():
|
| 130 |
+
enhance= gr.Checkbox(label="Randomize seed", value=False)
|
| 131 |
+
nologo=gr.Checkbox(label="nologo", value=False)
|
| 132 |
+
nofeed=gr.Checkbox(label="nofeed", value=False)
|
| 133 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
gr.Examples(examples=examples, inputs=[prompt])
|
| 136 |
gr.on(
|
|
|
|
| 138 |
fn=infer,
|
| 139 |
inputs=[
|
| 140 |
prompt,
|
|
|
|
| 141 |
seed,
|
| 142 |
randomize_seed,
|
| 143 |
width,
|
| 144 |
height,
|
| 145 |
+
enhance,
|
| 146 |
+
nologo, # Remove watermark (default: False)
|
| 147 |
+
nofeed=, # Don't add to public feed (default: False)
|
| 148 |
|
| 149 |
],
|
| 150 |
outputs=[result, seed],
|