John Ho commited on
Commit
e83d360
Β·
1 Parent(s): 556a97b

addeda application file

Browse files
Files changed (3) hide show
  1. README.md +4 -1
  2. app.py +28 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Moondream Pointer
3
- emoji: πŸ¦€
4
  colorFrom: indigo
5
  colorTo: red
6
  sdk: gradio
@@ -11,3 +11,6 @@ short_description: inference for moondream2 point API
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
  title: Moondream Pointer
3
+ emoji: πŸŒ•πŸŒ–πŸŒ—
4
  colorFrom: indigo
5
  colorTo: red
6
  sdk: gradio
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+ # Moondream Pointer
16
+ HuggingFace Space inference for moondream2's [point API](https://moondream.ai/c/docs/advanced/api/point) using code example from the [official doc](https://huggingface.co/vikhyatk/moondream2)
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import spaces, torch
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+ from PIL import Image
5
+
6
+
7
+ @spaces.GPU
8
+ def load_model():
9
+ return AutoModelForCausalLM.from_pretrained(
10
+ "vikhyatk/moondream2",
11
+ revision="2025-04-14",
12
+ trust_remote_code=True,
13
+ device_map={"": "cuda"},
14
+ )
15
+
16
+
17
+ @spaces.GPU
18
+ def point(im: Image.Image, object_name: str):
19
+ model = load_model()
20
+ return model.detect(im, object_name)["objects"]
21
+
22
+
23
+ demo = gr.Interface(
24
+ fn=point,
25
+ inputs=[gr.Image(label="Input Image"), gr.Textbox(label="Object to Detect")],
26
+ outputs=gr.Textbox(label="Output Text"),
27
+ )
28
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers==4.45.0
2
+ pydantic==2.10.6