mursalinir commited on
Commit
417971f
·
1 Parent(s): 5aa3e0d

update app.py

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +12 -4
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .gradio/certificate.pem
app.py CHANGED
@@ -25,14 +25,22 @@ prompt = (
25
 
26
  def caption_image(image):
27
  inputs = processor(images=image, text=prompt, return_tensors="pt").to(device)
28
- out = model.generate(**inputs, max_new_tokens=250, temperature=0.7, top_p=0.9)
29
- return processor.batch_decode(out, skip_special_tokens=True)[0]
 
 
 
 
 
 
 
 
30
 
31
  demo = gr.Interface(
32
  fn=caption_image,
33
- inputs=gr.Image(type="pil"),
34
  outputs="text",
35
  title="Image to Paragraph Captioning"
36
  )
37
 
38
- demo.launch()
 
25
 
26
  def caption_image(image):
27
  inputs = processor(images=image, text=prompt, return_tensors="pt").to(device)
28
+ out = model.generate(
29
+ **inputs,
30
+ max_new_tokens=250,
31
+ do_sample=True,
32
+ temperature=0.7,
33
+ top_p=0.9,
34
+ repetition_penalty=1.2)
35
+ output = processor.batch_decode(out, skip_special_tokens=True)[0]
36
+ print(output)
37
+ return output
38
 
39
  demo = gr.Interface(
40
  fn=caption_image,
41
+ inputs=gr.Image(type="pil", label="Upload an Image", height=400),
42
  outputs="text",
43
  title="Image to Paragraph Captioning"
44
  )
45
 
46
+ demo.queue(api_open=False, max_size=10).launch()