Spaces:
Running
on
Zero
Running
on
Zero
fallenshock
commited on
Commit
•
1f31600
1
Parent(s):
52b4b13
oauth 4
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ import random
|
|
9 |
import numpy as np
|
10 |
import spaces
|
11 |
import huggingface_hub
|
|
|
|
|
12 |
from FlowEdit_utils import FlowEditSD3, FlowEditFLUX
|
13 |
SD3STRING = 'stabilityai/stable-diffusion-3-medium'
|
14 |
FLUXSTRING = 'black-forest-labs/FLUX.1-dev'
|
@@ -77,30 +79,30 @@ def FlowEditRun(
|
|
77 |
|
78 |
):
|
79 |
|
80 |
-
if oauth_token is None:
|
81 |
-
|
82 |
-
if model_type == 'SD3':
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
elif model_type == 'FLUX':
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
else:
|
103 |
-
|
104 |
|
105 |
if not len(src_prompt):
|
106 |
raise gr.Error("source prompt cannot be empty")
|
@@ -116,10 +118,10 @@ def FlowEditRun(
|
|
116 |
|
117 |
if model_type == 'FLUX':
|
118 |
# pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.float16)
|
119 |
-
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16
|
120 |
loaded_model = 'FLUX'
|
121 |
elif model_type == 'SD3':
|
122 |
-
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16
|
123 |
loaded_model = 'SD3'
|
124 |
else:
|
125 |
raise NotImplementedError(f"Model type {model_type} not implemented")
|
@@ -235,6 +237,7 @@ with gr.Blocks() as demo:
|
|
235 |
|
236 |
|
237 |
gr.HTML(intro)
|
|
|
238 |
with gr.Row():
|
239 |
gr.LoginButton(value="Login to HF (For SD3 and FLUX access)", variant="primary")
|
240 |
|
|
|
9 |
import numpy as np
|
10 |
import spaces
|
11 |
import huggingface_hub
|
12 |
+
|
13 |
+
|
14 |
from FlowEdit_utils import FlowEditSD3, FlowEditFLUX
|
15 |
SD3STRING = 'stabilityai/stable-diffusion-3-medium'
|
16 |
FLUXSTRING = 'black-forest-labs/FLUX.1-dev'
|
|
|
79 |
|
80 |
):
|
81 |
|
82 |
+
# if oauth_token is None:
|
83 |
+
# raise gr.Error("You must be logged in to use Stable Diffusion 3.0 and FLUX.1 models.")
|
84 |
+
# if model_type == 'SD3':
|
85 |
+
# try:
|
86 |
+
# huggingface_hub.get_hf_file_metadata(huggingface_hub.hf_hub_url(SD3STRING, 'sd3_medium.safetensors'),
|
87 |
+
# token=oauth_token.token)
|
88 |
+
# print('Has Access')
|
89 |
+
# # except huggingface_hub.utils._errors.GatedRepoError:
|
90 |
+
# except huggingface_hub.errors.GatedRepoError:
|
91 |
+
# raise gr.Error("You need to accept the license agreement to use Stable Diffusion 3. "
|
92 |
+
# "Visit the <a href='https://huggingface.co/stabilityai/stable-diffusion-3-medium'>"
|
93 |
+
# "model page</a> to get access.")
|
94 |
+
# elif model_type == 'FLUX':
|
95 |
+
# try:
|
96 |
+
# huggingface_hub.get_hf_file_metadata(huggingface_hub.hf_hub_url(FLUXSTRING, 'flux1-dev.safetensors'),
|
97 |
+
# token=oauth_token.token)
|
98 |
+
# print('Has Access')
|
99 |
+
# # except huggingface_hub.utils._errors.GatedRepoError:
|
100 |
+
# except huggingface_hub.errors.GatedRepoError:
|
101 |
+
# raise gr.Error("You need to accept the license agreement to use FLUX.1. "
|
102 |
+
# "Visit the <a href='https://huggingface.co/black-forest-labs/FLUX.1-dev'>"
|
103 |
+
# "model page</a> to get access.")
|
104 |
+
# else:
|
105 |
+
# raise NotImplementedError(f"Model type {model_type} not implemented")
|
106 |
|
107 |
if not len(src_prompt):
|
108 |
raise gr.Error("source prompt cannot be empty")
|
|
|
118 |
|
119 |
if model_type == 'FLUX':
|
120 |
# pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.float16)
|
121 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)#, token=os.getenv('PRIV_TOKEN'))
|
122 |
loaded_model = 'FLUX'
|
123 |
elif model_type == 'SD3':
|
124 |
+
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)#, token=os.getenv('PRIV_TOKEN'))
|
125 |
loaded_model = 'SD3'
|
126 |
else:
|
127 |
raise NotImplementedError(f"Model type {model_type} not implemented")
|
|
|
237 |
|
238 |
|
239 |
gr.HTML(intro)
|
240 |
+
|
241 |
with gr.Row():
|
242 |
gr.LoginButton(value="Login to HF (For SD3 and FLUX access)", variant="primary")
|
243 |
|