whitphx HF staff commited on
Commit
7534432
1 Parent(s): 8b0b30f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +53 -16
index.html CHANGED
@@ -1,19 +1,56 @@
1
  <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
 
1
  <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
5
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
6
+ </head>
7
+ <body>
8
+ <gradio-lite>
9
+
10
+ <gradio-requirements>
11
+ transformers_js_py
12
+ </gradio-requirements>
13
+
14
+ <gradio-file name="app.py" entrypoint>
15
+ from transformers_js import import_transformers_js, as_url
16
+ import gradio as gr
17
+
18
+ transformers = await import_transformers_js()
19
+ pipeline = transformers.pipeline
20
+ pipe = await pipeline('object-detection', "Xenova/yolos-tiny")
21
+
22
+ async def detect(image):
23
+ result = await pipe(as_url(image))
24
+ gradio_labels = [
25
+ # List[Tuple[numpy.ndarray | Tuple[int, int, int, int], str]]
26
+ (
27
+ (
28
+ int(item["box"]["xmin"]),
29
+ int(item["box"]["ymin"]),
30
+ int(item["box"]["xmax"]),
31
+ int(item["box"]["ymax"]),
32
+ ),
33
+ item["label"],
34
+ )
35
+ for item in result
36
+ ]
37
+ annotated_image_data = image, gradio_labels
38
+ return annotated_image_data, result
39
+
40
+ demo = gr.Interface(
41
+ detect,
42
+ gr.Image(type="filepath"),
43
+ [
44
+ gr.AnnotatedImage(),
45
+ gr.JSON(),
46
+ ]
47
+ )
48
+
49
+ demo.launch()
50
+ </gradio-file>
51
+
52
+ </gradio-lite>
53
+
54
+ </body>
55
  </html>
56
+