Spaces:
Running
on
Zero
Running
on
Zero
Muhammadreza
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,33 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
import modin.pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
from diffusers import DiffusionPipeline
|
6 |
|
7 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
+
|
9 |
+
if torch.cuda.is_available():
|
10 |
+
torch.cuda.max_memory_allocated(device=device)
|
11 |
+
torch.cuda.empty_cache()
|
12 |
+
pipe = DiffusionPipeline.from_pretrained("mann-e/Mann-E_Turbo", torch_dtype=torch.float16)
|
13 |
+
pipe.enable_xformers_memory_efficient_attention()
|
14 |
+
pipe = pipe.to(device)
|
15 |
+
torch.cuda.empty_cache()
|
16 |
+
else:
|
17 |
+
pipe = DiffusionPipeline.from_pretrained("mann-e/Mann-E_Turbo", use_safetensors=True)
|
18 |
+
pipe = pipe.to(device)
|
19 |
+
|
20 |
+
def genie (prompt, negative_prompt, steps, seed):
|
21 |
+
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
22 |
+
int_image = pipe(prompt=prompt, negative_prompt=negative_prompt, generator=generator, num_inference_steps=steps, guidance_scale=0.0).images[0]
|
23 |
+
return int_image
|
24 |
+
|
25 |
+
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 75 Token Limit.'),
|
26 |
+
gr.Textbox(label='What you DO NOT want the AI to generate. 75 Token Limit.'),
|
27 |
+
gr.Slider(1, maximum=8, value=6, step=1, label='Number of Iterations'),
|
28 |
+
gr.Slider(minimum=0, step=1, maximum=999999999999999999, randomize=True),
|
29 |
+
],
|
30 |
+
outputs='image',
|
31 |
+
title="Mann-E Dreams",
|
32 |
+
description="Mann-E Dreams <br><br><b>WARNING: This model is capable of producing NSFW (Softcore) images.</b>",
|
33 |
+
article = "").launch(debug=True, max_threads=80)
|