artelabsuper commited on
Commit
21bf7d6
1 Parent(s): 8bb5da3
Files changed (4) hide show
  1. .gitignore +3 -0
  2. app.py +29 -0
  3. demo_imgs/fake.jpg +0 -0
  4. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ venv
2
+ *.pyc
3
+ __pycache__
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import torchvision
4
+ import torch
5
+
6
+ # load model
7
+
8
+ def predict(input_image):
9
+ pil_image = Image.fromarray(input_image.astype('uint8'), 'RGB')
10
+ # transform image to torch and do preprocessing
11
+ torch_image = torchvision.transforms.ToTensor()(pil_image)
12
+ # model predict
13
+ prediction = torch.rand(torch_image.shape)
14
+ # transform torch to image
15
+ predicted_pil_image = torchvision.transforms.ToPILImage()(prediction)
16
+ # return correct image
17
+ return predicted_pil_image
18
+
19
+ iface = gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(shape=(512,512)),
22
+ outputs=gr.Image(shape=(512,512)),
23
+ examples=[
24
+ ["demo_imgs/fake.jpg"] # use real image
25
+ ],
26
+ title="DTM Estimation",
27
+ description="This demo predict a DTM..."
28
+ )
29
+ iface.launch()
demo_imgs/fake.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torch
3
+ torchvision