xu3kev commited on
Commit
a9101d2
1 Parent(s): df70adb
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -224,7 +224,7 @@ def llm_call(question_prompt, model_name,
224
  top_p=1, n_samples=64, stop=None):
225
  if HUGGINGFACE:
226
  model_inputs = hug_tokenizer([question_prompt], return_tensors="pt").to('cuda')
227
- generated_ids = hug_model.generate(**model_inputs, max_length=1400, temperature=1, num_return_sequences=9, do_sample=True)
228
  responses = hug_tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
229
  codes = []
230
  for response in responses:
@@ -438,13 +438,14 @@ def main():
438
  gr.Markdown("""Here we can draw a target image using the sketchpad, and see what kinds of graphics program LLM generates. To allow the LLM to visually perceive the input image, we convert the image to ASCII strings.""")
439
  gr.Markdown("## Draw logo")
440
  with gr.Row():
441
- with gr.Column():
442
  canvas = gr.Sketchpad(canvas_size=(512,512), brush=Brush(colors=["black"], default_size=2, color_mode='fixed'))
443
  submit_button = gr.Button("Submit")
444
- output_gallery = gr.Gallery(
445
- label="Generated images", show_label=False, elem_id="gallery"
446
- , columns=[3], rows=[3], object_fit="contain", height="auto")
447
- # output_image = gr.Image(label="output")
 
448
 
449
  submit_button.click(img_to_code_img, inputs=canvas, outputs=output_gallery)
450
  demo.load(
 
224
  top_p=1, n_samples=64, stop=None):
225
  if HUGGINGFACE:
226
  model_inputs = hug_tokenizer([question_prompt], return_tensors="pt").to('cuda')
227
+ generated_ids = hug_model.generate(**model_inputs, max_length=1400, temperature=1, num_return_sequences=10, do_sample=True)
228
  responses = hug_tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
229
  codes = []
230
  for response in responses:
 
438
  gr.Markdown("""Here we can draw a target image using the sketchpad, and see what kinds of graphics program LLM generates. To allow the LLM to visually perceive the input image, we convert the image to ASCII strings.""")
439
  gr.Markdown("## Draw logo")
440
  with gr.Row():
441
+ with gr.Column(scale=1):
442
  canvas = gr.Sketchpad(canvas_size=(512,512), brush=Brush(colors=["black"], default_size=2, color_mode='fixed'))
443
  submit_button = gr.Button("Submit")
444
+ with gr.Column(scale=2):
445
+ output_gallery = gr.Gallery(
446
+ label="Generated images", show_label=False, elem_id="gallery"
447
+ , columns=[5], rows=[2], object_fit="contain", height="auto")
448
+ # output_image = gr.Image(label="output")
449
 
450
  submit_button.click(img_to_code_img, inputs=canvas, outputs=output_gallery)
451
  demo.load(