Spaces:
Runtime error
Runtime error
gaspar-avit
commited on
Commit
·
e1f7ecd
1
Parent(s):
b66b2da
Upload app.py
Browse files
app.py
CHANGED
@@ -177,7 +177,7 @@ def query_summarization(text):
|
|
177 |
response = requests.request("POST", API_URL, headers=headers, json=payload).json()
|
178 |
return response[0].get('summary_text')
|
179 |
|
180 |
-
def generate_poster(movie_data
|
181 |
"""
|
182 |
Function for recommending movies
|
183 |
-param movie_data: metadata of movie selected by user
|
@@ -195,7 +195,7 @@ def generate_poster(movie_data, _api):
|
|
195 |
# Load text-to-image model
|
196 |
if not IS_MODEL_LOADED:
|
197 |
with st.spinner("Loading Text to Image model..."):
|
198 |
-
pipeline = load_model(
|
199 |
|
200 |
# Get image based on synopsis
|
201 |
poster_image = pipeline(synopsis_sum).images[0]
|
@@ -216,10 +216,6 @@ if __name__ == "__main__":
|
|
216 |
# Initialize image variable
|
217 |
image = None
|
218 |
|
219 |
-
## Create dataset
|
220 |
-
data = load_dataset()
|
221 |
-
|
222 |
-
|
223 |
## --- Page config ------------ ##
|
224 |
# Set page title
|
225 |
st.title("""
|
@@ -228,12 +224,12 @@ if __name__ == "__main__":
|
|
228 |
Just select the title of a movie to generate an alternative poster.
|
229 |
""")
|
230 |
|
231 |
-
|
232 |
footer()
|
233 |
## ---------------------------- ##
|
234 |
|
235 |
## --- Connect to kaggle API --- #
|
236 |
-
|
237 |
if not os.path.exists(PATH_JSON):
|
238 |
api_token = {"username":st.secrets['username'],"key":st.secrets['key']}
|
239 |
with open(PATH_JSON, 'w') as file:
|
@@ -245,6 +241,8 @@ if __name__ == "__main__":
|
|
245 |
api.authenticate()
|
246 |
## ---------------------------- ##
|
247 |
|
|
|
|
|
248 |
|
249 |
st.text("")
|
250 |
st.text("")
|
@@ -262,7 +260,7 @@ if __name__ == "__main__":
|
|
262 |
|
263 |
|
264 |
if is_clicked:
|
265 |
-
image = generate_poster(data[data.title==session.selected_movie]
|
266 |
|
267 |
st.text("")
|
268 |
st.text("")
|
|
|
177 |
response = requests.request("POST", API_URL, headers=headers, json=payload).json()
|
178 |
return response[0].get('summary_text')
|
179 |
|
180 |
+
def generate_poster(movie_data):
|
181 |
"""
|
182 |
Function for recommending movies
|
183 |
-param movie_data: metadata of movie selected by user
|
|
|
195 |
# Load text-to-image model
|
196 |
if not IS_MODEL_LOADED:
|
197 |
with st.spinner("Loading Text to Image model..."):
|
198 |
+
pipeline = load_model()
|
199 |
|
200 |
# Get image based on synopsis
|
201 |
poster_image = pipeline(synopsis_sum).images[0]
|
|
|
216 |
# Initialize image variable
|
217 |
image = None
|
218 |
|
|
|
|
|
|
|
|
|
219 |
## --- Page config ------------ ##
|
220 |
# Set page title
|
221 |
st.title("""
|
|
|
224 |
Just select the title of a movie to generate an alternative poster.
|
225 |
""")
|
226 |
|
227 |
+
# Set page footer
|
228 |
footer()
|
229 |
## ---------------------------- ##
|
230 |
|
231 |
## --- Connect to kaggle API --- #
|
232 |
+
# Save key to json file
|
233 |
if not os.path.exists(PATH_JSON):
|
234 |
api_token = {"username":st.secrets['username'],"key":st.secrets['key']}
|
235 |
with open(PATH_JSON, 'w') as file:
|
|
|
241 |
api.authenticate()
|
242 |
## ---------------------------- ##
|
243 |
|
244 |
+
## Create dataset
|
245 |
+
data = load_dataset(api)
|
246 |
|
247 |
st.text("")
|
248 |
st.text("")
|
|
|
260 |
|
261 |
|
262 |
if is_clicked:
|
263 |
+
image = generate_poster(data[data.title==session.selected_movie])
|
264 |
|
265 |
st.text("")
|
266 |
st.text("")
|