implementing app
Browse files
app.py
CHANGED
@@ -51,10 +51,12 @@ st.title("Atom Level Entity Detector")
|
|
51 |
image_file = st.file_uploader("Upload a chemical structure candidate image",type=['png'])
|
52 |
#st.write('filename is', file_name)
|
53 |
if image_file is not None:
|
54 |
-
col1, col2 = st.columns(2)
|
55 |
|
56 |
image = Image.open(image_file)
|
57 |
-
col1.image(image, use_column_width=True)
|
|
|
|
|
58 |
if not os.path.exists("uploads/images"):
|
59 |
os.makedirs("uploads/images")
|
60 |
with open(os.path.join("uploads/images/","0.png"),"wb") as f:
|
@@ -63,14 +65,15 @@ if image_file is not None:
|
|
63 |
dataset.prepare_data()
|
64 |
trainer = pl.Trainer(logger=False)
|
65 |
atom_preds = trainer.predict(model_atom, dataset.test_dataloader())
|
66 |
-
st.write(atom_preds)
|
67 |
plt.imshow(image, cmap="gray")
|
68 |
for bbox, label in zip(atom_preds[0]['boxes'][0], atom_preds[0]['preds'][0]):
|
69 |
-
|
70 |
-
|
71 |
plot_bbox(bbox, label)
|
|
|
72 |
plt.savefig("example_image.png",bbox_inches='tight', pad_inches=0)
|
73 |
image_vis = Image.open("example_image.png")
|
74 |
-
|
75 |
#x = st.slider('Select a value')
|
76 |
#st.write(x, 'squared is', x * x)
|
|
|
51 |
image_file = st.file_uploader("Upload a chemical structure candidate image",type=['png'])
|
52 |
#st.write('filename is', file_name)
|
53 |
if image_file is not None:
|
54 |
+
#col1, col2 = st.columns(2)
|
55 |
|
56 |
image = Image.open(image_file)
|
57 |
+
#col1.image(image, use_column_width=True)
|
58 |
+
st.image(image, use_column_width=True)
|
59 |
+
col1, col2 = st.columns(2)
|
60 |
if not os.path.exists("uploads/images"):
|
61 |
os.makedirs("uploads/images")
|
62 |
with open(os.path.join("uploads/images/","0.png"),"wb") as f:
|
|
|
65 |
dataset.prepare_data()
|
66 |
trainer = pl.Trainer(logger=False)
|
67 |
atom_preds = trainer.predict(model_atom, dataset.test_dataloader())
|
68 |
+
#st.write(atom_preds)
|
69 |
plt.imshow(image, cmap="gray")
|
70 |
for bbox, label in zip(atom_preds[0]['boxes'][0], atom_preds[0]['preds'][0]):
|
71 |
+
# st.write(bbox)
|
72 |
+
# st.write(label)
|
73 |
plot_bbox(bbox, label)
|
74 |
+
plt.axis('off')
|
75 |
plt.savefig("example_image.png",bbox_inches='tight', pad_inches=0)
|
76 |
image_vis = Image.open("example_image.png")
|
77 |
+
col1.image(image_vis, use_column_width=True)
|
78 |
#x = st.slider('Select a value')
|
79 |
#st.write(x, 'squared is', x * x)
|