gaspar-avit commited on
Commit
ad562e0
1 Parent(s): 22d28a0

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -186,7 +186,9 @@ def query_generate(text):
186
  API_URL = "https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
187
  headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
188
  text = "Poster of movie. " + text
189
- payload = {"inputs": f"{text}",}
 
 
190
 
191
  response = requests.post(API_URL, headers=headers, json=payload)
192
  return response.content
@@ -201,10 +203,10 @@ def generate_poster(movie_data):
201
 
202
 
203
  # Get summarization of movie synopsis
 
204
  with st.spinner("Please wait while the synopsis is being summarized..."):
205
  synopsis_sum = query_summary(movie_data.overview.values[0])
206
 
207
- st.text("")
208
  st.text("")
209
  st.subheader("Synopsis:")
210
  st.text("Synopsis summary: " + synopsis_sum)
@@ -223,13 +225,12 @@ def generate_poster(movie_data):
223
  st.text("")
224
  st.text("")
225
  st.subheader("Resulting poster:")
226
- col1, col2, col3 = st.columns([1, 10, 1])
227
 
228
  with col1:
229
  st.write("")
230
 
231
  with col2:
232
- st.text("")
233
  st.image(image, caption="Movie: \"" + movie_data.title.values[0] + "\"")
234
 
235
  with col3:
@@ -278,7 +279,7 @@ if __name__ == "__main__":
278
  st.text("")
279
 
280
  ## Select box with all the movies as choices
281
- selected_movie = st.selectbox(label="Select a movie to generate alternative poster", options=data.title_year)
282
 
283
  st.text("")
284
  st.text("")
@@ -289,7 +290,7 @@ if __name__ == "__main__":
289
 
290
  ## Generate poster
291
  if is_clicked:
292
- poster = generate_poster(data[data.title_year==selected_movie])
293
  generate_poster.clear()
294
  st.runtime.legacy_caching.clear_cache()
295
 
 
186
  API_URL = "https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
187
  headers = {"Authorization": f"Bearer {st.secrets['hf_token']}"}
188
  text = "Poster of movie. " + text
189
+ payload = {"inputs": f"{text}",
190
+ "options": {"wait_for_model": True},
191
+ }
192
 
193
  response = requests.post(API_URL, headers=headers, json=payload)
194
  return response.content
 
203
 
204
 
205
  # Get summarization of movie synopsis
206
+ st.text("")
207
  with st.spinner("Please wait while the synopsis is being summarized..."):
208
  synopsis_sum = query_summary(movie_data.overview.values[0])
209
 
 
210
  st.text("")
211
  st.subheader("Synopsis:")
212
  st.text("Synopsis summary: " + synopsis_sum)
 
225
  st.text("")
226
  st.text("")
227
  st.subheader("Resulting poster:")
228
+ col1, col2, col3 = st.columns([1, 6, 1])
229
 
230
  with col1:
231
  st.write("")
232
 
233
  with col2:
 
234
  st.image(image, caption="Movie: \"" + movie_data.title.values[0] + "\"")
235
 
236
  with col3:
 
279
  st.text("")
280
 
281
  ## Select box with all the movies as choices
282
+ session.selected_movie = st.selectbox(label="Select a movie to generate alternative poster", options=data.title_year)
283
 
284
  st.text("")
285
  st.text("")
 
290
 
291
  ## Generate poster
292
  if is_clicked:
293
+ poster = generate_poster(data[data.title_year==session.selected_movie])
294
  generate_poster.clear()
295
  st.runtime.legacy_caching.clear_cache()
296