ThisHumanA
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import gc
|
|
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
from transformers import (
|
@@ -11,8 +12,19 @@ from transformers import (
|
|
11 |
import google.generativeai as genai
|
12 |
|
13 |
# Configure Generative AI
|
14 |
-
genai.configure(api_key=google_api_key)
|
15 |
-
gemini_model = genai.GenerativeModel("gemini-1.5-flash")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Load BLIP model and processor
|
18 |
@st.cache_resource
|
|
|
1 |
import streamlit as st
|
2 |
import gc
|
3 |
+
import os
|
4 |
from PIL import Image
|
5 |
import torch
|
6 |
from transformers import (
|
|
|
12 |
import google.generativeai as genai
|
13 |
|
14 |
# Configure Generative AI
|
15 |
+
# genai.configure(api_key=google_api_key)
|
16 |
+
# gemini_model = genai.GenerativeModel("gemini-1.5-flash")
|
17 |
+
|
18 |
+
# Configure Generative AI with API key from environment variable
|
19 |
+
|
20 |
+
|
21 |
+
api_key = os.getenv('google_api_key') # Retrieve the secret API key
|
22 |
+
if not api_key:
|
23 |
+
st.error("API key is missing. Please configure 'google_api_key' in your Hugging Face Secrets.")
|
24 |
+
else:
|
25 |
+
genai.configure(api_key=api_key)
|
26 |
+
gemini_model = genai.GenerativeModel("gemini-1.5-flash")
|
27 |
+
|
28 |
|
29 |
# Load BLIP model and processor
|
30 |
@st.cache_resource
|