Leyo commited on
Commit
c81aabf
1 Parent(s): dc439a7

few updates

Browse files
Files changed (1) hide show
  1. app_dialogue.py +9 -5
app_dialogue.py CHANGED
@@ -66,7 +66,7 @@ BAN_TOKENS = ( # For documentation puporse. We are not using this list, it is h
66
  EOS_STRINGS = ["<end_of_utterance>", "\nUser:"]
67
  STOP_SUSPECT_LIST = []
68
 
69
- GRADIO_LINK = "https://huggingfacem4-ai-meme-generator.hf.space"
70
  API_TOKEN = os.getenv("HF_AUTH_TOKEN")
71
  IDEFICS_LOGO = "https://huggingface.co/spaces/HuggingFaceM4/idefics_playground/resolve/main/IDEFICS_logo.png"
72
 
@@ -156,7 +156,7 @@ for image_dir in os.listdir("example_images"):
156
  tmp_filename = H.preprocess(H.value)
157
  DEFAULT_IMAGES_TMP_PATH_TO_URL[
158
  tmp_filename
159
- ] = f"https://huggingface.co/spaces/HuggingFaceM4/AI_Meme_Generator/resolve/main/example_images/{image_dir}/{im_path}"
160
 
161
 
162
  # Utils to handle the image markdown display logic
@@ -792,8 +792,12 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
792
  text_at_the_top,
793
  generation_args,
794
  ):
795
- time.sleep(random.uniform(0, 1))
796
- text = client.generate(prompt=query, **generation_args).generated_text
 
 
 
 
797
  if image is not None and text != "":
798
  meme_image = make_meme_image(
799
  image=image,
@@ -1007,4 +1011,4 @@ with gr.Blocks(title="AI Meme Generator", theme=gr.themes.Base(), css=css) as de
1007
  outputs=[template_gallery],
1008
  )
1009
  demo.queue(concurrency_count=8, max_size=40, api_open=False)
1010
- demo.launch(max_threads=400)
 
66
  EOS_STRINGS = ["<end_of_utterance>", "\nUser:"]
67
  STOP_SUSPECT_LIST = []
68
 
69
+ GRADIO_LINK = "https://leyo-ai-meme-generator.hf.space"
70
  API_TOKEN = os.getenv("HF_AUTH_TOKEN")
71
  IDEFICS_LOGO = "https://huggingface.co/spaces/HuggingFaceM4/idefics_playground/resolve/main/IDEFICS_logo.png"
72
 
 
156
  tmp_filename = H.preprocess(H.value)
157
  DEFAULT_IMAGES_TMP_PATH_TO_URL[
158
  tmp_filename
159
+ ] = f"https://huggingface.co/spaces/Leyo/AI_Meme_Generator/resolve/main/example_images/{image_dir}/{im_path}"
160
 
161
 
162
  # Utils to handle the image markdown display logic
 
792
  text_at_the_top,
793
  generation_args,
794
  ):
795
+ # time.sleep(random.uniform(0, 1))
796
+ try:
797
+ text = client.generate(prompt=query, **generation_args).generated_text
798
+ except Exception as e:
799
+ print(e)
800
+ text = "BACKEND ERROR"
801
  if image is not None and text != "":
802
  meme_image = make_meme_image(
803
  image=image,
 
1011
  outputs=[template_gallery],
1012
  )
1013
  demo.queue(concurrency_count=8, max_size=40, api_open=False)
1014
+ demo.launch(max_threads=400, prevent_thread_lock=True)