Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,8 +24,39 @@ MAX_IMAGE_SIZE = 2048
|
|
| 24 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
| 25 |
|
| 26 |
@spaces.GPU(duration=75)
|
| 27 |
-
def infer(
|
| 28 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
seed = random.randint(0, MAX_SEED)
|
| 30 |
generator = torch.Generator().manual_seed(seed)
|
| 31 |
|
|
@@ -50,7 +81,7 @@ examples = [
|
|
| 50 |
css="""
|
| 51 |
#col-container {
|
| 52 |
margin: 0 auto;
|
| 53 |
-
max-width:
|
| 54 |
}
|
| 55 |
"""
|
| 56 |
|
|
@@ -74,23 +105,23 @@ with gr.Blocks(css=css) as demo:
|
|
| 74 |
run_button = gr.Button("Run", scale=0)
|
| 75 |
|
| 76 |
with gr.Row():
|
| 77 |
-
|
| 78 |
choices=["Kaatz", "Mupp", "Hues", "Hamster"],
|
| 79 |
label="Hausdéier",
|
| 80 |
value="Kaatz"
|
| 81 |
)
|
| 82 |
|
| 83 |
with gr.Row():
|
| 84 |
-
|
| 85 |
choices=["Wunnzëmmer", "Graffiti Mauer", "Strooss", "Plage", "Bësch"],
|
| 86 |
label="Hannergronn",
|
| 87 |
value="Strooss"
|
| 88 |
)
|
| 89 |
|
| 90 |
with gr.Row():
|
| 91 |
-
|
| 92 |
choices=["Photo", "Cartoon", "Woll", "Aquarell", "3D"],
|
| 93 |
-
label="
|
| 94 |
value="Photo"
|
| 95 |
)
|
| 96 |
|
|
|
|
| 24 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
| 25 |
|
| 26 |
@spaces.GPU(duration=75)
|
| 27 |
+
def infer(name, pet, background, style, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
| 28 |
+
if pet == "Kaatz":
|
| 29 |
+
intro = "please generate an image of a cat sitting "
|
| 30 |
+
elif pet == "Mupp":
|
| 31 |
+
intro = "please generate an image of a dog sitting "
|
| 32 |
+
elif pet == "Hues":
|
| 33 |
+
intro = "please generate an image of a bunny sitting "
|
| 34 |
+
else:
|
| 35 |
+
intro = "please generate an image of an hamster sitting "
|
| 36 |
+
|
| 37 |
+
if background == "Wunnzëmmer":
|
| 38 |
+
place = intro + "in a living space "
|
| 39 |
+
elif background == "Grafitti Mauer":
|
| 40 |
+
place = intro + "in front of a wall with graffiti "
|
| 41 |
+
elif background == "Strooss":
|
| 42 |
+
place = intro + "in a street in the city "
|
| 43 |
+
elif background == "Plage":
|
| 44 |
+
place = intro + "at the beach "
|
| 45 |
+
else:
|
| 46 |
+
place = intro + " in the forest "
|
| 47 |
+
|
| 48 |
+
if style == "photo":
|
| 49 |
+
prompt = place + "holding a signal that says " + name + "in a photorealistic style"
|
| 50 |
+
elif style == "Cartoon":
|
| 51 |
+
prompt = place + "holding a signal that says " + name + "in a cartoon style"
|
| 52 |
+
elif style == "Woll":
|
| 53 |
+
prompt = place + "holding a signal that says " + name + "in a knitted with wool style"
|
| 54 |
+
elif style == "Aquarell":
|
| 55 |
+
prompt = place + "holding a signal that says " + name + "in a watercolorl style"
|
| 56 |
+
else:
|
| 57 |
+
prompt = place + "holding a signal that says " + name + "in a 3D style"
|
| 58 |
+
|
| 59 |
+
if randomize_seed:
|
| 60 |
seed = random.randint(0, MAX_SEED)
|
| 61 |
generator = torch.Generator().manual_seed(seed)
|
| 62 |
|
|
|
|
| 81 |
css="""
|
| 82 |
#col-container {
|
| 83 |
margin: 0 auto;
|
| 84 |
+
max-width: 640px;
|
| 85 |
}
|
| 86 |
"""
|
| 87 |
|
|
|
|
| 105 |
run_button = gr.Button("Run", scale=0)
|
| 106 |
|
| 107 |
with gr.Row():
|
| 108 |
+
pet = gr.Radio(
|
| 109 |
choices=["Kaatz", "Mupp", "Hues", "Hamster"],
|
| 110 |
label="Hausdéier",
|
| 111 |
value="Kaatz"
|
| 112 |
)
|
| 113 |
|
| 114 |
with gr.Row():
|
| 115 |
+
background = gr.Radio(
|
| 116 |
choices=["Wunnzëmmer", "Graffiti Mauer", "Strooss", "Plage", "Bësch"],
|
| 117 |
label="Hannergronn",
|
| 118 |
value="Strooss"
|
| 119 |
)
|
| 120 |
|
| 121 |
with gr.Row():
|
| 122 |
+
style = gr.Radio(
|
| 123 |
choices=["Photo", "Cartoon", "Woll", "Aquarell", "3D"],
|
| 124 |
+
label="Style",
|
| 125 |
value="Photo"
|
| 126 |
)
|
| 127 |
|