Ahsen Khaliq commited on
Commit
0fb713b
1 Parent(s): b15ed46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -18,14 +18,20 @@ import numpy as np
18
  from PIL import Image
19
  import gradio as gr
20
  import torch
 
 
21
 
22
  torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2017/09/11/15/58/sunset-2739472_1280.jpg', 'sunset.jpg')
23
 
 
 
 
 
24
  # Load ONNX model
25
- session = onnxruntime.InferenceSession('model.onnx')
26
 
27
  # Load output hash matrix
28
- seed1 = open('neuralhash_128x96_seed1.dat', 'rb').read()[128:]
29
  seed1 = np.frombuffer(seed1, dtype=np.float32)
30
  seed1 = seed1.reshape([96, 128])
31
 
 
18
  from PIL import Image
19
  import gradio as gr
20
  import torch
21
+ import zipfile
22
+
23
 
24
  torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2017/09/11/15/58/sunset-2739472_1280.jpg', 'sunset.jpg')
25
 
26
+ torch.hub.download_url_to_file('https://github.com/AsuharietYgvar/AppleNeuralHash2ONNX/files/7008624/apple-neural-hash.zip', '.')
27
+
28
+ with zipfile.ZipFile('apple-neural-hash.zip', 'r') as zip_ref:
29
+ zip_ref.extractall('.')
30
  # Load ONNX model
31
+ session = onnxruntime.InferenceSession('apple-neural-hash/model.onnx')
32
 
33
  # Load output hash matrix
34
+ seed1 = open('apple-neural-hash/neuralhash_128x96_seed1.dat', 'rb').read()[128:]
35
  seed1 = np.frombuffer(seed1, dtype=np.float32)
36
  seed1 = seed1.reshape([96, 128])
37