Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
•
baafb27
1
Parent(s):
4adc3f9
Update app.py
Browse files
app.py
CHANGED
@@ -17,8 +17,9 @@ import onnxruntime
|
|
17 |
import numpy as np
|
18 |
from PIL import Image
|
19 |
import gradio as gr
|
|
|
20 |
|
21 |
-
|
22 |
|
23 |
# Load ONNX model
|
24 |
session = onnxruntime.InferenceSession('model.onnx')
|
@@ -48,8 +49,9 @@ def inference(img):
|
|
48 |
return hash_hex
|
49 |
|
50 |
title = "AppleNeuralHash"
|
51 |
-
description = "Gradio demo for Apple NeuralHash
|
52 |
article = "<p style='text-align: center'><a href='https://github.com/AsuharietYgvar/AppleNeuralHash2ONNX'>Github Repo</a></p>"
|
|
|
53 |
|
54 |
gr.Interface(
|
55 |
inference,
|
@@ -57,5 +59,6 @@ gr.Interface(
|
|
57 |
gr.outputs.Textbox(label="Output Text"),
|
58 |
title=title,
|
59 |
description=description,
|
60 |
-
article=article
|
|
|
61 |
).launch(debug=True)
|
|
|
17 |
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')
|
|
|
49 |
return hash_hex
|
50 |
|
51 |
title = "AppleNeuralHash"
|
52 |
+
description = "Gradio demo for Apple NeuralHash, a perceptual hashing method for images based on neural networks. It can tolerate image resize and compression. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|
53 |
article = "<p style='text-align: center'><a href='https://github.com/AsuharietYgvar/AppleNeuralHash2ONNX'>Github Repo</a></p>"
|
54 |
+
examples = [['sunset.jpg']]
|
55 |
|
56 |
gr.Interface(
|
57 |
inference,
|
|
|
59 |
gr.outputs.Textbox(label="Output Text"),
|
60 |
title=title,
|
61 |
description=description,
|
62 |
+
article=article,
|
63 |
+
examples=examples
|
64 |
).launch(debug=True)
|