Spaces:
Running
on
Zero
Running
on
Zero
fallenshock
commited on
Commit
•
52b4b13
1
Parent(s):
d4ee1f3
add oauth precheck
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ import numpy as np
|
|
10 |
import spaces
|
11 |
import huggingface_hub
|
12 |
from FlowEdit_utils import FlowEditSD3, FlowEditFLUX
|
13 |
-
|
14 |
-
|
15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
# device = "cpu"
|
17 |
# model_type = 'SD3'
|
@@ -78,7 +78,29 @@ def FlowEditRun(
|
|
78 |
):
|
79 |
|
80 |
if oauth_token is None:
|
81 |
-
raise gr.Error("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
if not len(src_prompt):
|
84 |
raise gr.Error("source prompt cannot be empty")
|
|
|
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'
|
15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
# device = "cpu"
|
17 |
# model_type = 'SD3'
|
|
|
78 |
):
|
79 |
|
80 |
if oauth_token is None:
|
81 |
+
raise gr.Error("You must be logged in to use Stable Diffusion 3.0 and FLUX.1 models.")
|
82 |
+
if model_type == 'SD3':
|
83 |
+
try:
|
84 |
+
huggingface_hub.get_hf_file_metadata(huggingface_hub.hf_hub_url(SD3STRING, 'sd3_medium.safetensors'),
|
85 |
+
token=oauth_token.token)
|
86 |
+
print('Has Access')
|
87 |
+
# except huggingface_hub.utils._errors.GatedRepoError:
|
88 |
+
except huggingface_hub.errors.GatedRepoError:
|
89 |
+
raise gr.Error("You need to accept the license agreement to use Stable Diffusion 3. "
|
90 |
+
"Visit the <a href='https://huggingface.co/stabilityai/stable-diffusion-3-medium'>"
|
91 |
+
"model page</a> to get access.")
|
92 |
+
elif model_type == 'FLUX':
|
93 |
+
try:
|
94 |
+
huggingface_hub.get_hf_file_metadata(huggingface_hub.hf_hub_url(FLUXSTRING, 'flux1-dev.safetensors'),
|
95 |
+
token=oauth_token.token)
|
96 |
+
print('Has Access')
|
97 |
+
# except huggingface_hub.utils._errors.GatedRepoError:
|
98 |
+
except huggingface_hub.errors.GatedRepoError:
|
99 |
+
raise gr.Error("You need to accept the license agreement to use FLUX.1. "
|
100 |
+
"Visit the <a href='https://huggingface.co/black-forest-labs/FLUX.1-dev'>"
|
101 |
+
"model page</a> to get access.")
|
102 |
+
else:
|
103 |
+
raise NotImplementedError(f"Model type {model_type} not implemented")
|
104 |
|
105 |
if not len(src_prompt):
|
106 |
raise gr.Error("source prompt cannot be empty")
|