kumar989 commited on
Commit
c9f727d
·
1 Parent(s): ccdef3b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import os
3
+ import streamlit as st
4
+ import requests
5
+ from PIL import Image
6
+ from model import bone_frac
7
+
8
+
9
+ @st.cache(allow_output_mutation=True)
10
+ # def get_model():
11
+ # return get_caption_model()
12
+
13
+ # caption_model = get_model()
14
+ pred_model=bone_frac()
15
+
16
+ # def predict():
17
+ # captions = []
18
+ # pred_caption = generate_caption('tmp.jpg', caption_model)
19
+
20
+ # st.markdown('#### Predicted Captions:')
21
+ # captions.append(pred_caption)
22
+
23
+ # for _ in range(4):
24
+ # pred_caption = generate_caption('tmp.jpg', caption_model, add_noise=True)
25
+ # if pred_caption not in captions:
26
+ # captions.append(pred_caption)
27
+
28
+ # for c in captions:
29
+ # st.write(c)
30
+
31
+ st.title('Bone Fracture Detection')
32
+ img_url = st.text_input(label='Enter Image URL')
33
+
34
+ if (img_url != "") and (img_url != None):
35
+ img = Image.open(requests.get(img_url, stream=True).raw)
36
+ img = img.convert('RGB')
37
+ st.image(img)
38
+ img.save('tmp.jpg')
39
+ predict()
40
+ os.remove('tmp.jpg')
41
+
42
+
43
+ st.markdown('<center style="opacity: 70%">OR</center>', unsafe_allow_html=True)
44
+ img_upload = st.file_uploader(label='Upload Image', type=['jpg', 'png', 'jpeg'])
45
+
46
+ if img_upload != None:
47
+ img = img_upload.read()
48
+ img = Image.open(io.BytesIO(img))
49
+ img = img.convert('RGB')
50
+ img.save('tmp.jpg')
51
+ st.image(img)
52
+ st.write(pred_model(img))
53
+ os.remove('tmp.jpg')