gaspar-avit commited on
Commit
57728b1
·
1 Parent(s): adce41b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -177,7 +177,7 @@ def query_summary(text):
177
  return text
178
 
179
 
180
- def query_generate(text):
181
  """
182
  Get image from HuggingFace Inference API
183
  -param text: text to generate image
@@ -185,7 +185,8 @@ def query_generate(text):
185
  """
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)
@@ -209,6 +210,10 @@ def generate_poster(movie_data):
209
  -return: image of generated alternative poster
210
  """
211
 
 
 
 
 
212
  # Get summarization of movie synopsis
213
  st.text("")
214
  with st.spinner("Please wait while the synopsis is being summarized..."):
@@ -227,7 +232,7 @@ def generate_poster(movie_data):
227
 
228
  # Get image based on synopsis
229
  with st.spinner("Generating poster image..."):
230
- response_content = query_generate(synopsis_sum)
231
 
232
  # Show image
233
  try:
 
177
  return text
178
 
179
 
180
+ def query_generate(text, genres):
181
  """
182
  Get image from HuggingFace Inference API
183
  -param text: text to generate image
 
185
  """
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 + '. ' + genres
189
+ st.wrtie(text)
190
  payload = {"inputs": f"{text}",}
191
 
192
  response = requests.post(API_URL, headers=headers, json=payload)
 
210
  -return: image of generated alternative poster
211
  """
212
 
213
+ # Get movie genres
214
+ genres = [i['name'] for i in eval(movie_data['genres'])]
215
+ genres_string = ', '.join(genres)
216
+
217
  # Get summarization of movie synopsis
218
  st.text("")
219
  with st.spinner("Please wait while the synopsis is being summarized..."):
 
232
 
233
  # Get image based on synopsis
234
  with st.spinner("Generating poster image..."):
235
+ response_content = query_generate(synopsis_sum, genres_string)
236
 
237
  # Show image
238
  try: