Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -9,15 +9,14 @@ import gradio as gr
|
|
9 |
import numpy as np
|
10 |
from lxml.html import fromstring
|
11 |
from pathos.threading import ThreadPool as Pool
|
12 |
-
from diffusers import FlaxDiffusionPipeline
|
13 |
#from diffusers.pipelines.flux import FluxPipeline
|
14 |
#from diffusers.utils import export_to_gif
|
15 |
#from huggingface_hub import hf_hub_download
|
16 |
#from safetensors.torch import load_file
|
17 |
-
|
18 |
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
-
pipe =
|
21 |
|
22 |
def translate(text,lang):
|
23 |
|
@@ -95,10 +94,10 @@ def Piper(_do,neg):
|
|
95 |
return None
|
96 |
|
97 |
@spaces.GPU(duration=25)
|
98 |
-
def
|
99 |
-
|
100 |
-
print(
|
101 |
-
return
|
102 |
|
103 |
def infer(p1,p2):
|
104 |
name = generate_random_string(12)+".png"
|
@@ -107,7 +106,7 @@ def infer(p1,p2):
|
|
107 |
_do.append(f'{p1}')
|
108 |
if p2 != "":
|
109 |
_dont = f'{p2} where in {p1}'
|
110 |
-
neg =
|
111 |
else:
|
112 |
neg = None
|
113 |
output = Piper('A '+" ".join(_do),neg)
|
|
|
9 |
import numpy as np
|
10 |
from lxml.html import fromstring
|
11 |
from pathos.threading import ThreadPool as Pool
|
|
|
12 |
#from diffusers.pipelines.flux import FluxPipeline
|
13 |
#from diffusers.utils import export_to_gif
|
14 |
#from huggingface_hub import hf_hub_download
|
15 |
#from safetensors.torch import load_file
|
16 |
+
from diffusers import FlaxStableDiffusionPipeline
|
17 |
|
18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
+
pipe = FlaxStableDiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, token=os.getenv("hf_token")).to(device)
|
20 |
|
21 |
def translate(text,lang):
|
22 |
|
|
|
94 |
return None
|
95 |
|
96 |
@spaces.GPU(duration=25)
|
97 |
+
def tok(txt):
|
98 |
+
toks = pipe.prepare_inputs(txt)
|
99 |
+
print(toks)
|
100 |
+
return toks
|
101 |
|
102 |
def infer(p1,p2):
|
103 |
name = generate_random_string(12)+".png"
|
|
|
106 |
_do.append(f'{p1}')
|
107 |
if p2 != "":
|
108 |
_dont = f'{p2} where in {p1}'
|
109 |
+
neg = tok(_dont)
|
110 |
else:
|
111 |
neg = None
|
112 |
output = Piper('A '+" ".join(_do),neg)
|