daniyal214 commited on
Commit
eef44a6
1 Parent(s): d52eb24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,12 +1,18 @@
1
  import gradio as gr
2
  from transformers import pipeline
 
 
3
 
4
- pipe = pipeline("image-to-text", model="daniyal214/finetuned-git-large-chest-xrays")
5
 
6
- def get_captions(image):
7
- result = pipe(image)
8
- result = result[0]['generated_text']
9
- return result
 
 
 
 
10
 
11
  iface = gr.Interface(fn = get_captions, inputs = "image", outputs = ['text'], title="X-rays Image Caption Generator")
12
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ from PIL import Image
4
+ import numpy as np
5
 
6
+ pipe = pipeline("image-to-text", model="daniyal214/finetuned-blip-chest-xrays")
7
 
8
+ def get_captions(input_image):
9
+ # Convert the received image to a PIL Image
10
+ image = Image.fromarray((input_image * 255).astype(np.uint8))
11
+
12
+ # Pass the PIL image to the pipeline
13
+ result = pipe(image)
14
+ result = result[0]['generated_text']
15
+ return result
16
 
17
  iface = gr.Interface(fn = get_captions, inputs = "image", outputs = ['text'], title="X-rays Image Caption Generator")
18
  iface.launch()