Fizzarolli commited on
Commit
4e2b6d8
1 Parent(s): 5c9b0ca
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -15,10 +15,10 @@ model.to("cuda")
15
  processor = AutoProcessor.from_pretrained(MODEL_ID)
16
 
17
  @spaces.GPU
18
- def tag_image(image):
19
  inputs = processor(images=image, text="<image>tag en", return_tensors="pt")
20
  streamer = TextIteratorStreamer(tokenizer=processor.tokenizer, skip_prompt=True)
21
- generation_kwargs = dict(inputs, streamer=streamer)
22
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
23
 
24
  text = ""
@@ -33,7 +33,7 @@ def tag_image(image):
33
 
34
  gr.Interface(
35
  fn=tag_image,
36
- inputs=[gr.Image(type="pil")],
37
  outputs=gr.Textbox(type="text"),
38
  title=TITLE,
39
  description=DESCRIPTION,
 
15
  processor = AutoProcessor.from_pretrained(MODEL_ID)
16
 
17
  @spaces.GPU
18
+ def tag_image(image, max_new_tokens=128):
19
  inputs = processor(images=image, text="<image>tag en", return_tensors="pt")
20
  streamer = TextIteratorStreamer(tokenizer=processor.tokenizer, skip_prompt=True)
21
+ generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=max_new_tokens)
22
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
23
 
24
  text = ""
 
33
 
34
  gr.Interface(
35
  fn=tag_image,
36
+ inputs=[gr.Image(type="pil"), gr.Slider(minimum=1, maximum=1024, value=128)],
37
  outputs=gr.Textbox(type="text"),
38
  title=TITLE,
39
  description=DESCRIPTION,