Rodrigo_Cobo
commited on
Commit
·
c372dd5
1
Parent(s):
272c5b4
save images as PNG
Browse files
app.py
CHANGED
|
@@ -6,15 +6,16 @@ import urllib.request
|
|
| 6 |
import numpy as np
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
from PIL import Image
|
|
|
|
| 9 |
|
| 10 |
def calculate_depth(model_type, img):
|
| 11 |
|
| 12 |
if not os.path.exists('temp'):
|
| 13 |
os.system('mkdir temp')
|
| 14 |
|
| 15 |
-
filename = "Images/Input-Test/0.
|
| 16 |
|
| 17 |
-
img.save(filename, "
|
| 18 |
|
| 19 |
midas = torch.hub.load("intel-isl/MiDaS", model_type)
|
| 20 |
|
|
@@ -48,16 +49,16 @@ def calculate_depth(model_type, img):
|
|
| 48 |
|
| 49 |
formatted = (output * 255.0 / np.max(output)).astype('uint8')
|
| 50 |
out_im = Image.fromarray(formatted)
|
| 51 |
-
out_im.save("Images/Input-Test/0_d.
|
| 52 |
|
| 53 |
return out_im
|
| 54 |
|
| 55 |
def wiggle_effect(slider):
|
| 56 |
|
| 57 |
-
|
| 58 |
|
|
|
|
| 59 |
|
| 60 |
-
#pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
|
| 61 |
|
| 62 |
with gr.Blocks() as demo:
|
| 63 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
from PIL import Image
|
| 9 |
+
import subprocess
|
| 10 |
|
| 11 |
def calculate_depth(model_type, img):
|
| 12 |
|
| 13 |
if not os.path.exists('temp'):
|
| 14 |
os.system('mkdir temp')
|
| 15 |
|
| 16 |
+
filename = "Images/Input-Test/0.png"
|
| 17 |
|
| 18 |
+
img.save(filename, "PNG")
|
| 19 |
|
| 20 |
midas = torch.hub.load("intel-isl/MiDaS", model_type)
|
| 21 |
|
|
|
|
| 49 |
|
| 50 |
formatted = (output * 255.0 / np.max(output)).astype('uint8')
|
| 51 |
out_im = Image.fromarray(formatted)
|
| 52 |
+
out_im.save("Images/Input-Test/0_d.png", "PNG")
|
| 53 |
|
| 54 |
return out_im
|
| 55 |
|
| 56 |
def wiggle_effect(slider):
|
| 57 |
|
| 58 |
+
#subprocess.run(['echo', 'arg1'])
|
| 59 |
|
| 60 |
+
return [f'Images/Input-Test/1_d.png',f'Images/Input-Test/1_d.png']
|
| 61 |
|
|
|
|
| 62 |
|
| 63 |
with gr.Blocks() as demo:
|
| 64 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|