Update app.py
Browse files
app.py
CHANGED
|
@@ -51,10 +51,14 @@ def infer(
|
|
| 51 |
num_inference_steps=40,
|
| 52 |
progress=gr.Progress(track_tqdm=True),
|
| 53 |
):
|
| 54 |
-
if randomize_seed:
|
| 55 |
-
seed = random.randint(0, MAX_SEED)
|
| 56 |
-
generator = torch.Generator().manual_seed(seed)
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
try:
|
| 59 |
image = pipe(
|
| 60 |
prompt=prompt,
|
|
@@ -70,10 +74,6 @@ def infer(
|
|
| 70 |
print(f"Error during image generation: {e}") # Print error for debugging
|
| 71 |
return f"Error: {e}", seed # Return error to Gradio interface
|
| 72 |
|
| 73 |
-
# ... (rest of your Gradio code - examples, CSS, etc. - same as before)
|
| 74 |
-
examples = [
|
| 75 |
-
"A capybara wearing a suit holding a sign that reads Hello World",
|
| 76 |
-
]
|
| 77 |
|
| 78 |
css = """
|
| 79 |
#col-container {
|
|
|
|
| 51 |
num_inference_steps=40,
|
| 52 |
progress=gr.Progress(track_tqdm=True),
|
| 53 |
):
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
if randomize_seed:
|
| 56 |
+
seed = random.randint(0, MAX_SEED) # Generate a new seed if randomize_seed is True
|
| 57 |
+
else:
|
| 58 |
+
seed = seed # Use the user-provided seed
|
| 59 |
+
|
| 60 |
+
generator = torch.Generator(device=device).manual_seed(seed) # Ensure the generator is on the correct device
|
| 61 |
+
|
| 62 |
try:
|
| 63 |
image = pipe(
|
| 64 |
prompt=prompt,
|
|
|
|
| 74 |
print(f"Error during image generation: {e}") # Print error for debugging
|
| 75 |
return f"Error: {e}", seed # Return error to Gradio interface
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
css = """
|
| 79 |
#col-container {
|