whitphx HF staff commited on
Commit
15683b1
1 Parent(s): a1fd9eb

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +21 -19
index.html CHANGED
@@ -20,37 +20,39 @@
20
  <body>
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
 
23
  import gradio as gr
24
 
25
- from filters import as_gray
 
 
26
 
27
- def process(input_image):
28
- output_image = as_gray(input_image)
29
- return output_image
 
 
30
 
31
  demo = gr.Interface(
32
- process,
33
- "image",
34
- "image",
35
- examples=["lion.jpg", "logo.png"],
 
 
 
 
 
 
36
  )
37
 
38
  demo.launch()
39
  </gradio-file>
40
 
41
- <gradio-file name="filters.py">
42
- from skimage.color import rgb2gray
43
-
44
- def as_gray(image):
45
- return rgb2gray(image)
46
- </gradio-file>
47
-
48
- <gradio-file name="lion.jpg" url="https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/test_data/lion.jpg" />
49
- <gradio-file name="logo.png" url="https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png" />
50
 
51
  <gradio-requirements>
52
- # Same syntax as requirements.txt
53
- scikit-image
54
  </gradio-requirements>
55
  </gradio-lite>
56
  </body>
 
20
  <body>
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
23
+ from transformers_js import import_transformers_js, as_url
24
  import gradio as gr
25
 
26
+ transformers = await import_transformers_js()
27
+ pipeline = transformers.pipeline
28
+ depth_estimator = await pipeline('depth-estimation', 'Xenova/depth-anything-large-hf');
29
 
30
+
31
+ async def estimate(input_image):
32
+ output = await depth_estimator(as_url(input_image))
33
+ # print("blob:", output.depth.toBlob())
34
+ return output
35
 
36
  demo = gr.Interface(
37
+ fn=estimate,
38
+ inputs=[
39
+ gr.Image(type="filepath")
40
+ ],
41
+ outputs=[
42
+ gr.JSON(),
43
+ ],
44
+ examples=[
45
+ ["bread_small.png"]
46
+ ]
47
  )
48
 
49
  demo.launch()
50
  </gradio-file>
51
 
52
+ <gradio-file name="bread_small.png" url="https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/bread_small.png" />
 
 
 
 
 
 
 
 
53
 
54
  <gradio-requirements>
55
+ transformers_js_py
 
56
  </gradio-requirements>
57
  </gradio-lite>
58
  </body>