Spaces:
Runtime error
Runtime error
alexander-lazarin
commited on
Commit
·
8a13e97
1
Parent(s):
3823333
Manage secrets in Colab and HF
Browse files- Fashion_MVP_v0_0_2.ipynb +15 -2
- app.py +15 -2
Fashion_MVP_v0_0_2.ipynb
CHANGED
@@ -164,7 +164,12 @@
|
|
164 |
"source": [
|
165 |
"#|export\n",
|
166 |
"import openai\n",
|
167 |
-
"
|
|
|
|
|
|
|
|
|
|
|
168 |
"from openai import OpenAI\n",
|
169 |
"from IPython.display import Image\n",
|
170 |
"\n",
|
@@ -257,6 +262,14 @@
|
|
257 |
"#|export\n",
|
258 |
"os.makedirs('images', exist_ok=True)\n",
|
259 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
"client = OpenAI(\n",
|
261 |
" api_key=userdata.get('OPEN_AI_KEY'), # 'OPENAI_API_KEY'\n",
|
262 |
" base_url=\"https://api.openai.com/v1/\"\n",
|
@@ -461,7 +474,7 @@
|
|
461 |
" channel_id = \"1222929433682378787\",\n",
|
462 |
" version = \"1166847114203123795\",\n",
|
463 |
" id = \"938956540159881230\",\n",
|
464 |
-
" authorization = \
|
465 |
" )\n",
|
466 |
" path = get_latest_file_path(\"./images/\")\n",
|
467 |
" gen_image_type = \"mj\"\n",
|
|
|
164 |
"source": [
|
165 |
"#|export\n",
|
166 |
"import openai\n",
|
167 |
+
"\n",
|
168 |
+
"try:\n",
|
169 |
+
" from google.colab import userdata\n",
|
170 |
+
" IN_COLAB = True\n",
|
171 |
+
"except:\n",
|
172 |
+
" IN_COLAB = False\n",
|
173 |
"from openai import OpenAI\n",
|
174 |
"from IPython.display import Image\n",
|
175 |
"\n",
|
|
|
262 |
"#|export\n",
|
263 |
"os.makedirs('images', exist_ok=True)\n",
|
264 |
"\n",
|
265 |
+
"\n",
|
266 |
+
"if IN_COLAB:\n",
|
267 |
+
" OPEN_AI_KEY = userdata.get('OPEN_AI_KEY')\n",
|
268 |
+
" MJ_AUTH = userdata.get('MJ_AUTH')\n",
|
269 |
+
"else:\n",
|
270 |
+
" OPEN_AI_KEY = os.environ['API_TOKEN']\n",
|
271 |
+
" MJ_AUTH = os.environ['MJ_AUTH']\n",
|
272 |
+
"\n",
|
273 |
"client = OpenAI(\n",
|
274 |
" api_key=userdata.get('OPEN_AI_KEY'), # 'OPENAI_API_KEY'\n",
|
275 |
" base_url=\"https://api.openai.com/v1/\"\n",
|
|
|
474 |
" channel_id = \"1222929433682378787\",\n",
|
475 |
" version = \"1166847114203123795\",\n",
|
476 |
" id = \"938956540159881230\",\n",
|
477 |
+
" authorization = MJ_AUTH\n",
|
478 |
" )\n",
|
479 |
" path = get_latest_file_path(\"./images/\")\n",
|
480 |
" gen_image_type = \"mj\"\n",
|
app.py
CHANGED
@@ -9,7 +9,12 @@ __all__ = ['client', 'vision_model', 'chat_model', 'text2img_model', 'initial_pr
|
|
9 |
|
10 |
# %% Fashion_MVP_v0_0_2.ipynb 8
|
11 |
import openai
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
from openai import OpenAI
|
14 |
from IPython.display import Image
|
15 |
|
@@ -84,6 +89,14 @@ def get_latest_file_path(directory):
|
|
84 |
# %% Fashion_MVP_v0_0_2.ipynb 10
|
85 |
os.makedirs('images', exist_ok=True)
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
client = OpenAI(
|
88 |
api_key=userdata.get('OPEN_AI_KEY'), # 'OPENAI_API_KEY'
|
89 |
base_url="https://api.openai.com/v1/"
|
@@ -252,7 +265,7 @@ def generate_image(brand_name, style_name, initial_prompt, brand_prompt, brand_r
|
|
252 |
channel_id = "1222929433682378787",
|
253 |
version = "1166847114203123795",
|
254 |
id = "938956540159881230",
|
255 |
-
authorization =
|
256 |
)
|
257 |
path = get_latest_file_path("./images/")
|
258 |
gen_image_type = "mj"
|
|
|
9 |
|
10 |
# %% Fashion_MVP_v0_0_2.ipynb 8
|
11 |
import openai
|
12 |
+
|
13 |
+
try:
|
14 |
+
from google.colab import userdata
|
15 |
+
IN_COLAB = True
|
16 |
+
except:
|
17 |
+
IN_COLAB = False
|
18 |
from openai import OpenAI
|
19 |
from IPython.display import Image
|
20 |
|
|
|
89 |
# %% Fashion_MVP_v0_0_2.ipynb 10
|
90 |
os.makedirs('images', exist_ok=True)
|
91 |
|
92 |
+
|
93 |
+
if IN_COLAB:
|
94 |
+
OPEN_AI_KEY = userdata.get('OPEN_AI_KEY')
|
95 |
+
MJ_AUTH = userdata.get('MJ_AUTH')
|
96 |
+
else:
|
97 |
+
OPEN_AI_KEY = os.environ['API_TOKEN']
|
98 |
+
MJ_AUTH = os.environ['MJ_AUTH']
|
99 |
+
|
100 |
client = OpenAI(
|
101 |
api_key=userdata.get('OPEN_AI_KEY'), # 'OPENAI_API_KEY'
|
102 |
base_url="https://api.openai.com/v1/"
|
|
|
265 |
channel_id = "1222929433682378787",
|
266 |
version = "1166847114203123795",
|
267 |
id = "938956540159881230",
|
268 |
+
authorization = MJ_AUTH
|
269 |
)
|
270 |
path = get_latest_file_path("./images/")
|
271 |
gen_image_type = "mj"
|