Spaces:
Sleeping
Sleeping
Andre
commited on
Commit
·
96410e5
1
Parent(s):
21e7c28
Update
Browse files- colab.ipynb +1 -4
- config.py +11 -4
colab.ipynb
CHANGED
@@ -6,16 +6,13 @@
|
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
9 |
"# Import necessary libraries\n",
|
10 |
"import random\n",
|
11 |
"import ipywidgets as widgets\n",
|
12 |
"from IPython.display import display, clear_output\n",
|
13 |
"from img_gen_logic import generate_image\n",
|
14 |
"from config import models, prompts\n",
|
15 |
-
"from google.colab import userdata\n",
|
16 |
-
"\n",
|
17 |
-
"# Retrieve the Hugging Face token from Colab secrets\n",
|
18 |
-
"api_token = userdata.get(\"HF_CTB_TOKEN\")\n",
|
19 |
"\n",
|
20 |
"# Dropdown menu for model selection\n",
|
21 |
"model_dropdown = widgets.Dropdown(\n",
|
|
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
9 |
+
"# colab.ipynb\n",
|
10 |
"# Import necessary libraries\n",
|
11 |
"import random\n",
|
12 |
"import ipywidgets as widgets\n",
|
13 |
"from IPython.display import display, clear_output\n",
|
14 |
"from img_gen_logic import generate_image\n",
|
15 |
"from config import models, prompts\n",
|
|
|
|
|
|
|
|
|
16 |
"\n",
|
17 |
"# Dropdown menu for model selection\n",
|
18 |
"model_dropdown = widgets.Dropdown(\n",
|
config.py
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
-
#
|
2 |
import os
|
|
|
3 |
|
4 |
-
# Retrieve the Hugging Face token
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Debugging: Check if the Hugging Face token is available
|
8 |
if not api_token:
|
9 |
-
print("ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable.")
|
10 |
else:
|
11 |
print("Hugging Face token loaded successfully.")
|
12 |
|
|
|
13 |
# List of models with aliases
|
14 |
models = [
|
15 |
{"alias": "FLUX.1-dev", "name": "black-forest-labs/FLUX.1-dev"},
|
|
|
1 |
+
# config.py
|
2 |
import os
|
3 |
+
from google.colab import userdata # Only for Colab
|
4 |
|
5 |
+
# Retrieve the Hugging Face token
|
6 |
+
try:
|
7 |
+
# Try to get the token from Colab secrets
|
8 |
+
api_token = userdata.get("HF_CTB_TOKEN")
|
9 |
+
except ImportError:
|
10 |
+
# Fall back to environment variable (for local execution)
|
11 |
+
api_token = os.getenv("HF_CTB_TOKEN")
|
12 |
|
13 |
# Debugging: Check if the Hugging Face token is available
|
14 |
if not api_token:
|
15 |
+
print("ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable or in Colab secrets.")
|
16 |
else:
|
17 |
print("Hugging Face token loaded successfully.")
|
18 |
|
19 |
+
|
20 |
# List of models with aliases
|
21 |
models = [
|
22 |
{"alias": "FLUX.1-dev", "name": "black-forest-labs/FLUX.1-dev"},
|