Spaces:
Paused
Paused
Commit
·
55002dc
1
Parent(s):
eecb045
Enhance image generation function by initializing random number generator for device-specific operations; update markdown instructions for clarity and improve HTML header formatting
Browse files
app.py
CHANGED
|
@@ -507,6 +507,7 @@ def generate_image(prompt, cfg, tau, h_div_w, seed):
|
|
| 507 |
torch.cuda.empty_cache()
|
| 508 |
|
| 509 |
with torch.amp.autocast(device_type=device, dtype=autocast_dtype), torch.no_grad():
|
|
|
|
| 510 |
_, _, img_list = infinity.autoregressive_infer_cfg(
|
| 511 |
vae=vae,
|
| 512 |
scale_schedule=scale_schedule,
|
|
@@ -520,6 +521,7 @@ def generate_image(prompt, cfg, tau, h_div_w, seed):
|
|
| 520 |
gt_leak=0, gt_ls_Bl=None, inference_mode=True,
|
| 521 |
sampling_per_bits=args.sampling_per_bits,
|
| 522 |
)
|
|
|
|
| 523 |
|
| 524 |
img = img_list[0]
|
| 525 |
image = img.cpu().numpy()
|
|
@@ -531,18 +533,16 @@ def generate_image(prompt, cfg, tau, h_div_w, seed):
|
|
| 531 |
|
| 532 |
markdown_description = """### Instructions:
|
| 533 |
|
| 534 |
-
1. Enter a prompt
|
| 535 |
-
2. Adjust the CFG
|
| 536 |
-
3.
|
| 537 |
-
4.
|
| 538 |
-
5. Click the Generate Image button to generate an image based on the prompt.
|
| 539 |
|
| 540 |
Arxiv Paper:
|
| 541 |
[Infinity: Scaling Bitwise AutoRegressive Modeling for High-Resolution Image Synthesis](https://arxiv.org/abs/2412.04431).
|
| 542 |
"""
|
| 543 |
html_header = """<div style="text-align: center; margin-bottom: 20px;">
|
| 544 |
-
<h1>Infinity Image Generator</h1>
|
| 545 |
-
<h2>by <a href="https://github.com/FoundationVision/Infinity" target="_blank" rel="noopener noreferrer">FoundationVision</a></h2>
|
| 546 |
<p style="font-size: 14px; color: #888;">This is not the official implementation from the main developers!</p>
|
| 547 |
</div>"""
|
| 548 |
with gr.Blocks() as demo:
|
|
|
|
| 507 |
torch.cuda.empty_cache()
|
| 508 |
|
| 509 |
with torch.amp.autocast(device_type=device, dtype=autocast_dtype), torch.no_grad():
|
| 510 |
+
infinity.rng = torch.Generator(device=device)
|
| 511 |
_, _, img_list = infinity.autoregressive_infer_cfg(
|
| 512 |
vae=vae,
|
| 513 |
scale_schedule=scale_schedule,
|
|
|
|
| 521 |
gt_leak=0, gt_ls_Bl=None, inference_mode=True,
|
| 522 |
sampling_per_bits=args.sampling_per_bits,
|
| 523 |
)
|
| 524 |
+
infinity.rng = torch.Generator(device="cpu")
|
| 525 |
|
| 526 |
img = img_list[0]
|
| 527 |
image = img.cpu().numpy()
|
|
|
|
| 533 |
|
| 534 |
markdown_description = """### Instructions:
|
| 535 |
|
| 536 |
+
1. Enter a detailed prompt with rich visual features or use the "Enhance Prompt" button to generate a more detailed description.
|
| 537 |
+
2. Adjust the "CFG" and "Tau" sliders to control the strength and randomness of the output.
|
| 538 |
+
3. Use the "Aspect Ratio" slider to set the aspect ratio of the generated image.
|
| 539 |
+
4. Click the "Generate Image" button to create the image based on your prompt.
|
|
|
|
| 540 |
|
| 541 |
Arxiv Paper:
|
| 542 |
[Infinity: Scaling Bitwise AutoRegressive Modeling for High-Resolution Image Synthesis](https://arxiv.org/abs/2412.04431).
|
| 543 |
"""
|
| 544 |
html_header = """<div style="text-align: center; margin-bottom: 20px;">
|
| 545 |
+
<h1>Infinity Image Generator by <a href="https://github.com/FoundationVision/Infinity" target="_blank" rel="noopener noreferrer">FoundationVision</a></h1>
|
|
|
|
| 546 |
<p style="font-size: 14px; color: #888;">This is not the official implementation from the main developers!</p>
|
| 547 |
</div>"""
|
| 548 |
with gr.Blocks() as demo:
|