Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Installer les dépendances Python et ngrok
|
| 2 |
+
!pip install gradio decimer
|
| 3 |
+
|
| 4 |
+
from google.colab import drive
|
| 5 |
+
drive.mount('/content/drive')
|
| 6 |
+
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import tempfile
|
| 10 |
+
from DECIMER import predict_SMILES
|
| 11 |
+
|
| 12 |
+
def predict_fn(img):
|
| 13 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
| 14 |
+
img.save(tmp, format="PNG")
|
| 15 |
+
path = tmp.name
|
| 16 |
+
return predict_SMILES(path)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=predict_fn, # prend en entrée un objet PIL.Image
|
| 21 |
+
inputs=gr.Image(type="pil"),
|
| 22 |
+
outputs="text"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
iface.launch(share=True, show_error=True)
|
| 26 |
+
# Le lien public s'affichera dans les logs
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|