jetson-examples 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jetson_examples-0.0.3.data/data/scripts/run.sh +451 -0
- {jetson_examples-0.0.1.dist-info → jetson_examples-0.0.3.dist-info}/METADATA +2 -2
- jetson_examples-0.0.3.dist-info/RECORD +9 -0
- jetson_examples-0.0.1.data/data/scripts/run.sh +0 -173
- jetson_examples-0.0.1.dist-info/RECORD +0 -9
- {jetson_examples-0.0.1.dist-info → jetson_examples-0.0.3.dist-info}/LICENSE +0 -0
- {jetson_examples-0.0.1.dist-info → jetson_examples-0.0.3.dist-info}/WHEEL +0 -0
- {jetson_examples-0.0.1.dist-info → jetson_examples-0.0.3.dist-info}/entry_points.txt +0 -0
- {jetson_examples-0.0.1.dist-info → jetson_examples-0.0.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,451 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
check_is_jetson_or_not() {
|
4
|
+
model_file="/proc/device-tree/model"
|
5
|
+
|
6
|
+
if [ -f "$model_file" ]; then
|
7
|
+
first_line=$(head -n 1 "$model_file")
|
8
|
+
|
9
|
+
if [[ "$first_line" == NVIDIA* ]]; then
|
10
|
+
echo "INFO: jetson machine confirmed..."
|
11
|
+
else
|
12
|
+
echo "WARNING: your machine maybe not support..."
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
else
|
16
|
+
echo "ERROR: only jetson support this..."
|
17
|
+
exit 1
|
18
|
+
fi
|
19
|
+
}
|
20
|
+
check_is_jetson_or_not
|
21
|
+
|
22
|
+
check_disk_space() {
|
23
|
+
directory="$1" # a directory
|
24
|
+
required_space_gb="$2" # how many GB we need
|
25
|
+
|
26
|
+
# get disk of directory
|
27
|
+
device=$(df -P "$directory" | awk 'NR==2 {print $1}')
|
28
|
+
echo $device
|
29
|
+
|
30
|
+
# get free space in KB
|
31
|
+
free_space=$(df -P "$device" | awk 'NR==2 {print $4}')
|
32
|
+
echo $free_space
|
33
|
+
|
34
|
+
# change unit to GB
|
35
|
+
free_space_gb=$(echo "scale=2; $free_space / 1024 / 1024" | bc)
|
36
|
+
echo $free_space_gb
|
37
|
+
|
38
|
+
# check and fast-fail
|
39
|
+
if (( $(echo "$free_space_gb >= $required_space_gb" | bc -l) )); then
|
40
|
+
echo "disk space ($1) enough, keep going."
|
41
|
+
else
|
42
|
+
echo "disk space ($1) not enough!! we need $2 GB!!"
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
}
|
46
|
+
|
47
|
+
echo "run example:$1"
|
48
|
+
BASE_PATH=/home/$USER/reComputer
|
49
|
+
echo "----example init----"
|
50
|
+
mkdir -p $BASE_PATH/
|
51
|
+
JETSON_REPO_PATH="$BASE_PATH/jetson-containers"
|
52
|
+
if [ -d $JETSON_REPO_PATH ]; then
|
53
|
+
echo "jetson-ai-lab existed."
|
54
|
+
else
|
55
|
+
echo "jetson-ai-lab does not installed. start init..."
|
56
|
+
cd $BASE_PATH/
|
57
|
+
git clone --depth=1 https://github.com/dusty-nv/jetson-containers
|
58
|
+
cd $JETSON_REPO_PATH
|
59
|
+
sudo apt update; sudo apt install -y python3-pip
|
60
|
+
pip3 install -r requirements.txt
|
61
|
+
fi
|
62
|
+
echo "----example start----"
|
63
|
+
cd $JETSON_REPO_PATH
|
64
|
+
case "$1" in
|
65
|
+
"llava")
|
66
|
+
./run.sh $(./autotag llava) \
|
67
|
+
python3 -m llava.serve.cli \
|
68
|
+
--model-path liuhaotian/llava-v1.5-7b \
|
69
|
+
--image-file /data/images/hoover.jpg
|
70
|
+
;;
|
71
|
+
"llava-v1.5-7b")
|
72
|
+
./run.sh $(./autotag llava) \
|
73
|
+
python3 -m llava.serve.cli \
|
74
|
+
--model-path liuhaotian/llava-v1.5-7b \
|
75
|
+
--image-file /data/images/hoover.jpg
|
76
|
+
;;
|
77
|
+
"llava-v1.6-vicuna-7b")
|
78
|
+
./run.sh $(./autotag local_llm) \
|
79
|
+
python3 -m local_llm --api=mlc \
|
80
|
+
--model liuhaotian/llava-v1.6-vicuna-7b \
|
81
|
+
--max-context-len 768 \
|
82
|
+
--max-new-tokens 128
|
83
|
+
;;
|
84
|
+
"Sheared-LLaMA-2.7B-ShareGPT")
|
85
|
+
./run.sh $(./autotag local_llm) \
|
86
|
+
python3 -m local_llm.chat --api=mlc \
|
87
|
+
--model princeton-nlp/Sheared-LLaMA-2.7B-ShareGPT
|
88
|
+
;;
|
89
|
+
"text-generation-webui")
|
90
|
+
# download llm model
|
91
|
+
./run.sh --workdir=/opt/text-generation-webui $(./autotag text-generation-webui) /bin/bash -c \
|
92
|
+
'python3 download-model.py --output=/data/models/text-generation-webui TheBloke/Llama-2-7b-Chat-GPTQ'
|
93
|
+
# run text-generation-webui
|
94
|
+
./run.sh $(./autotag text-generation-webui)
|
95
|
+
;;
|
96
|
+
"stable-diffusion-webui")
|
97
|
+
./run.sh $(./autotag stable-diffusion-webui)
|
98
|
+
;;
|
99
|
+
"nanoowl")
|
100
|
+
./run.sh $(./autotag nanoowl) bash -c "ls /dev/video* && cd examples/tree_demo && python3 tree_demo.py ../../data/owl_image_encoder_patch32.engine"
|
101
|
+
;;
|
102
|
+
"whisper")
|
103
|
+
./run.sh $(./autotag whisper)
|
104
|
+
;;
|
105
|
+
"nanodb")
|
106
|
+
# check data files TODO: support params to force download
|
107
|
+
DATA_PATH="$JETSON_REPO_PATH/data/datasets/coco/2017"
|
108
|
+
if [ ! -d $DATA_PATH ]; then
|
109
|
+
mkdir -p $DATA_PATH
|
110
|
+
fi
|
111
|
+
cd $DATA_PATH
|
112
|
+
# check val2017.zip
|
113
|
+
if [ ! -d "$DATA_PATH/val2017" ]; then
|
114
|
+
if [ ! -f "val2017.zip" ]; then
|
115
|
+
check_disk_space $DATA_PATH 1
|
116
|
+
wget http://images.cocodataset.org/zips/val2017.zip
|
117
|
+
else
|
118
|
+
echo "val2017.zip existed."
|
119
|
+
fi
|
120
|
+
check_disk_space $DATA_PATH 19
|
121
|
+
unzip val2017.zip && rm val2017.zip
|
122
|
+
else
|
123
|
+
echo "val2017/ existed."
|
124
|
+
fi
|
125
|
+
# check train2017.zip
|
126
|
+
if [ ! -d "$DATA_PATH/train2017" ]; then
|
127
|
+
if [ ! -f "train2017.zip" ]; then
|
128
|
+
check_disk_space $DATA_PATH 19
|
129
|
+
wget http://images.cocodataset.org/zips/train2017.zip
|
130
|
+
else
|
131
|
+
echo "train2017.zip existed."
|
132
|
+
fi
|
133
|
+
check_disk_space $DATA_PATH 19
|
134
|
+
unzip train2017.zip && rm train2017.zip
|
135
|
+
else
|
136
|
+
echo "train2017/ existed."
|
137
|
+
fi
|
138
|
+
if [ ! -d "$DATA_PATH/unlabeled2017" ]; then
|
139
|
+
# check unlabeled2017.zip
|
140
|
+
if [ ! -f "unlabeled2017.zip" ]; then
|
141
|
+
check_disk_space $DATA_PATH 19
|
142
|
+
wget http://images.cocodataset.org/zips/unlabeled2017.zip
|
143
|
+
else
|
144
|
+
echo "unlabeled2017.zip existed."
|
145
|
+
fi
|
146
|
+
check_disk_space $DATA_PATH 19
|
147
|
+
unzip unlabeled2017.zip && rm unlabeled2017.zip
|
148
|
+
else
|
149
|
+
echo "unlabeled2017/ existed."
|
150
|
+
fi
|
151
|
+
|
152
|
+
# check index files
|
153
|
+
INDEX_PATH="$JETSON_REPO_PATH/data/nanodb/coco/2017"
|
154
|
+
if [ ! -d $INDEX_PATH ]; then
|
155
|
+
cd $JETSON_REPO_PATH/data/
|
156
|
+
check_disk_space $JETSON_REPO_PATH 1
|
157
|
+
wget https://nvidia.box.com/shared/static/icw8qhgioyj4qsk832r4nj2p9olsxoci.gz -O nanodb_coco_2017.tar.gz
|
158
|
+
tar -xzvf nanodb_coco_2017.tar.gz
|
159
|
+
fi
|
160
|
+
|
161
|
+
# RUN
|
162
|
+
cd $JETSON_REPO_PATH
|
163
|
+
./run.sh $(./autotag nanodb) \
|
164
|
+
python3 -m nanodb \
|
165
|
+
--path /data/nanodb/coco/2017 \
|
166
|
+
--server --port=7860
|
167
|
+
;;
|
168
|
+
"live-llava")
|
169
|
+
SUPPORT_L4T_LIST="35.3.1"
|
170
|
+
BASE_PATH=/home/$USER/reComputer
|
171
|
+
JETSON_REPO_PATH="$BASE_PATH/jetson-containers"
|
172
|
+
|
173
|
+
get_l4t_version() {
|
174
|
+
ARCH=$(uname -i)
|
175
|
+
echo "ARCH: $ARCH"
|
176
|
+
|
177
|
+
if [ $ARCH = "aarch64" ]; then
|
178
|
+
L4T_VERSION_STRING=$(head -n 1 /etc/nv_tegra_release)
|
179
|
+
|
180
|
+
if [ -z "$L4T_VERSION_STRING" ]; then
|
181
|
+
echo "reading L4T version from \"dpkg-query --show nvidia-l4t-core\""
|
182
|
+
L4T_VERSION_STRING=$(dpkg-query --showformat='${Version}' --show nvidia-l4t-core)
|
183
|
+
L4T_VERSION_ARRAY=(${L4T_VERSION_STRING//./ })
|
184
|
+
L4T_RELEASE=${L4T_VERSION_ARRAY[0]}
|
185
|
+
L4T_REVISION=${L4T_VERSION_ARRAY[1]}
|
186
|
+
else
|
187
|
+
echo "reading L4T version from /etc/nv_tegra_release"
|
188
|
+
L4T_RELEASE=$(echo $L4T_VERSION_STRING | cut -f 2 -d ' ' | grep -Po '(?<=R)[^;]+')
|
189
|
+
L4T_REVISION=$(echo $L4T_VERSION_STRING | cut -f 2 -d ',' | grep -Po '(?<=REVISION: )[^;]+')
|
190
|
+
fi
|
191
|
+
|
192
|
+
L4T_REVISION_MAJOR=${L4T_REVISION:0:1}
|
193
|
+
L4T_REVISION_MINOR=${L4T_REVISION:2:1}
|
194
|
+
L4T_VERSION="$L4T_RELEASE.$L4T_REVISION"
|
195
|
+
|
196
|
+
echo "L4T_VERSION: $L4T_VERSION"
|
197
|
+
|
198
|
+
elif [ $ARCH != "x86_64" ]; then
|
199
|
+
echo "unsupported architecture: $ARCH" # show in red color
|
200
|
+
exit 1
|
201
|
+
fi
|
202
|
+
}
|
203
|
+
|
204
|
+
# 1. Check L4T version
|
205
|
+
get_l4t_version
|
206
|
+
CHECK_L4T_VERSION=0
|
207
|
+
for item in $SUPPORT_L4T_LIST; do
|
208
|
+
if [ "$item" = "$L4T_VERSION" ]; then
|
209
|
+
CHECK_L4T_VERSION=1
|
210
|
+
break
|
211
|
+
fi
|
212
|
+
done
|
213
|
+
|
214
|
+
if [ $CHECK_L4T_VERSION -eq 1 ]; then
|
215
|
+
echo "pass the version check"
|
216
|
+
else
|
217
|
+
echo "currently supported versions of jetpack are $SUPPORT_L4T_LIST" # show in red color
|
218
|
+
exit 1
|
219
|
+
fi
|
220
|
+
|
221
|
+
# 2. Check Google Chrome
|
222
|
+
if dpkg -s chromium-browser &>/dev/null; then
|
223
|
+
echo "Chrome is installed."
|
224
|
+
else
|
225
|
+
echo "install Google Chrome ..." # show in red color
|
226
|
+
sudo apt install chromium-browser
|
227
|
+
echo "Google Chrome installed successfully" # show in red color
|
228
|
+
fi
|
229
|
+
|
230
|
+
# 3. Generate Google browser key
|
231
|
+
FILE_NAME="key.pem"
|
232
|
+
FILE_PATH="$JETSON_REPO_PATH/data"
|
233
|
+
if [ -f "$FILE_PATH/$FILE_NAME" ]; then
|
234
|
+
echo "key file '$FILE_PATH/$FILE_NAME' exists."
|
235
|
+
else
|
236
|
+
cd $FILE_PATH
|
237
|
+
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -subj '/CN=localhost'
|
238
|
+
cd ..
|
239
|
+
fi
|
240
|
+
|
241
|
+
# 4. edit source code
|
242
|
+
cat >"$JETSON_REPO_PATH/packages/llm/local_llm/agents/video_query.py" <<'EOF'
|
243
|
+
#!/usr/bin/env python3
|
244
|
+
import time
|
245
|
+
import logging
|
246
|
+
import threading
|
247
|
+
|
248
|
+
from local_llm import Agent
|
249
|
+
|
250
|
+
from local_llm.plugins import (
|
251
|
+
VideoSource,
|
252
|
+
VideoOutput,
|
253
|
+
ChatQuery,
|
254
|
+
PrintStream,
|
255
|
+
ProcessProxy,
|
256
|
+
)
|
257
|
+
from local_llm.utils import ArgParser, print_table
|
258
|
+
|
259
|
+
from termcolor import cprint
|
260
|
+
from jetson_utils import cudaFont, cudaMemcpy, cudaToNumpy, cudaDeviceSynchronize
|
261
|
+
|
262
|
+
from flask import Flask, request
|
263
|
+
|
264
|
+
|
265
|
+
class VideoQuery(Agent):
|
266
|
+
"""
|
267
|
+
Perpetual always-on closed-loop visual agent that applies prompts to a video stream.
|
268
|
+
"""
|
269
|
+
|
270
|
+
def __init__(self, model="liuhaotian/llava-v1.5-7b", **kwargs):
|
271
|
+
super().__init__()
|
272
|
+
self.lock = threading.Lock()
|
273
|
+
|
274
|
+
# load model in another process for smooth streaming
|
275
|
+
# self.llm = ProcessProxy((lambda **kwargs: ChatQuery(model, drop_inputs=True, **kwargs)), **kwargs)
|
276
|
+
self.llm = ChatQuery(model, drop_inputs=True, **kwargs)
|
277
|
+
self.llm.add(PrintStream(color="green", relay=True).add(self.on_text))
|
278
|
+
self.llm.start()
|
279
|
+
|
280
|
+
# test / warm-up query
|
281
|
+
self.warmup = True
|
282
|
+
self.text = ""
|
283
|
+
self.eos = False
|
284
|
+
|
285
|
+
self.llm("What is 2+2?")
|
286
|
+
|
287
|
+
while self.warmup:
|
288
|
+
time.sleep(0.25)
|
289
|
+
|
290
|
+
# create video streams
|
291
|
+
self.video_source = VideoSource(**kwargs)
|
292
|
+
self.video_output = VideoOutput(**kwargs)
|
293
|
+
|
294
|
+
self.video_source.add(self.on_video, threaded=False)
|
295
|
+
self.video_output.start()
|
296
|
+
|
297
|
+
self.font = cudaFont()
|
298
|
+
|
299
|
+
# setup prompts
|
300
|
+
self.prompt = "Describe the image concisely and briefly."
|
301
|
+
|
302
|
+
# entry node
|
303
|
+
self.pipeline = [self.video_source]
|
304
|
+
|
305
|
+
def on_video(self, image):
|
306
|
+
np_image = cudaToNumpy(image)
|
307
|
+
cudaDeviceSynchronize()
|
308
|
+
|
309
|
+
self.llm(
|
310
|
+
[
|
311
|
+
"reset",
|
312
|
+
np_image,
|
313
|
+
self.prompt,
|
314
|
+
]
|
315
|
+
)
|
316
|
+
|
317
|
+
text = self.text.replace("\n", "").replace("</s>", "").strip()
|
318
|
+
|
319
|
+
if text:
|
320
|
+
worlds = text.split()
|
321
|
+
line_counter = len(worlds) // 10
|
322
|
+
if len(worlds) % 10 != 0:
|
323
|
+
line_counter += 1
|
324
|
+
for l in range(line_counter):
|
325
|
+
line_text = " ".join(worlds[l * 10 : (l + 1) * 10])
|
326
|
+
self.font.OverlayText(
|
327
|
+
image,
|
328
|
+
text=line_text,
|
329
|
+
x=5,
|
330
|
+
y=int(79 + l * 37),
|
331
|
+
color=self.font.White,
|
332
|
+
background=self.font.Gray40,
|
333
|
+
)
|
334
|
+
self.font.OverlayText(
|
335
|
+
image,
|
336
|
+
text="Prompt: " + self.prompt,
|
337
|
+
x=5,
|
338
|
+
y=42,
|
339
|
+
color=(120, 215, 21),
|
340
|
+
background=self.font.Gray40,
|
341
|
+
)
|
342
|
+
self.video_output(image)
|
343
|
+
|
344
|
+
def on_text(self, text):
|
345
|
+
if self.eos:
|
346
|
+
self.text = text # new query response
|
347
|
+
self.eos = False
|
348
|
+
elif not self.warmup: # don't view warmup response
|
349
|
+
self.text = self.text + text
|
350
|
+
|
351
|
+
if text.endswith("</s>") or text.endswith("###") or text.endswith("<|im_end|>"):
|
352
|
+
self.print_stats()
|
353
|
+
self.warmup = False
|
354
|
+
self.eos = True
|
355
|
+
|
356
|
+
def update_switch(self, on_off):
|
357
|
+
self.video_source.switch(on_off)
|
358
|
+
|
359
|
+
def update_prompts(self, new_prompt):
|
360
|
+
with self.lock:
|
361
|
+
if new_prompt:
|
362
|
+
self.prompt = new_prompt
|
363
|
+
|
364
|
+
def print_stats(self):
|
365
|
+
# print_table(self.llm.model.stats)
|
366
|
+
curr_time = time.perf_counter()
|
367
|
+
|
368
|
+
if not hasattr(self, "start_time"):
|
369
|
+
self.start_time = curr_time
|
370
|
+
else:
|
371
|
+
frame_time = curr_time - self.start_time
|
372
|
+
self.start_time = curr_time
|
373
|
+
logging.info(
|
374
|
+
f"refresh rate: {1.0 / frame_time:.2f} FPS ({frame_time*1000:.1f} ms)"
|
375
|
+
)
|
376
|
+
|
377
|
+
|
378
|
+
if __name__ == "__main__":
|
379
|
+
parser = ArgParser(extras=ArgParser.Defaults + ["video_input", "video_output"])
|
380
|
+
args = parser.parse_args()
|
381
|
+
# 独立线程运行
|
382
|
+
agent = VideoQuery(**vars(args))
|
383
|
+
|
384
|
+
def run_video_query():
|
385
|
+
agent.run()
|
386
|
+
|
387
|
+
video_query_thread = threading.Thread(target=run_video_query)
|
388
|
+
video_query_thread.start()
|
389
|
+
|
390
|
+
# 启动web服务
|
391
|
+
app = Flask(__name__)
|
392
|
+
|
393
|
+
@app.route("/update_prompt", methods=["POST"])
|
394
|
+
def update_prompts():
|
395
|
+
prompt = request.json.get("prompt")
|
396
|
+
if prompt:
|
397
|
+
agent.update_prompts(prompt)
|
398
|
+
return "Prompts updated successfully."
|
399
|
+
else:
|
400
|
+
return "Invalid prompts data."
|
401
|
+
|
402
|
+
@app.route("/update_switch", methods=["POST"])
|
403
|
+
def update_switch():
|
404
|
+
infer_or_not = True if request.json.get("switch") == "on" else False
|
405
|
+
agent.update_switch(infer_or_not)
|
406
|
+
return "stop" if not infer_or_not else "start"
|
407
|
+
|
408
|
+
@app.route("/update_params", methods=["POST"])
|
409
|
+
def update_params():
|
410
|
+
try:
|
411
|
+
agent.llm.max_new_tokens = request.json.get("max_new_tokens") or 128
|
412
|
+
agent.llm.min_new_tokens = request.json.get("min_new_tokens") or -1
|
413
|
+
agent.llm.do_sample = request.json.get("do_sample") or False
|
414
|
+
agent.llm.repetition_penalty = request.json.get("repetition_penalty") or 1.0
|
415
|
+
agent.llm.temperature = request.json.get("temperature") or 0.7
|
416
|
+
agent.llm.top_p = request.json.get("top_p") or 0.95
|
417
|
+
if request.json.get("system_prompt"):
|
418
|
+
agent.llm.chat_history.template["system_prompt"] = request.json.get(
|
419
|
+
"system_prompt"
|
420
|
+
)
|
421
|
+
return "params updated."
|
422
|
+
except Exception as e:
|
423
|
+
print(e)
|
424
|
+
return "update failure"
|
425
|
+
|
426
|
+
app.run(host="0.0.0.0", port=5555)
|
427
|
+
|
428
|
+
|
429
|
+
EOF
|
430
|
+
|
431
|
+
sed -i 's/from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection, SiglipImageProcessor, SiglipVisionModel/from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection # , SiglipImageProcessor, SiglipVisionModel/' "$JETSON_REPO_PATH/packages/llm/local_llm/vision/clip_hf.py"
|
432
|
+
sed -i "s/'siglip': dict(preprocessor=SiglipImageProcessor, model=SiglipVisionModel),/# 'siglip': dict(preprocessor=SiglipImageProcessor, model=SiglipVisionModel),/" "$JETSON_REPO_PATH/packages/llm/local_llm/vision/clip_hf.py"
|
433
|
+
|
434
|
+
sed -i 's/from .audio import */# from .audio import */' "$JETSON_REPO_PATH/packages/llm/local_llm/plugins/__init__.py"
|
435
|
+
sed -i 's/from .nanodb import NanoDB/# from .nanodb import NanoDB/' "$JETSON_REPO_PATH/packages/llm/local_llm/plugins/__init__.py"
|
436
|
+
|
437
|
+
sed -i 's/import onnxruntime as ort/# import onnxruntime as ort/' "$JETSON_REPO_PATH/packages/llm/local_llm/utils/model.py"
|
438
|
+
|
439
|
+
echo "The script has been modified."
|
440
|
+
|
441
|
+
# gnome-terminal -- /bin/bash -c chromium-browser --disable-features=WebRtcHideLocalIpsWithMdns https://localhost:8554/"; exec /bin/bash"
|
442
|
+
|
443
|
+
cd $JETSON_REPO_PATH
|
444
|
+
sudo docker run --runtime nvidia -it --rm --network host --volume /tmp/argus_socket:/tmp/argus_socket --volume /etc/enctune.conf:/etc/enctune.conf --volume /etc/nv_tegra_release:/etc/nv_tegra_release --volume /proc/device-tree/model:/tmp/nv_jetson_model --volume /var/run/dbus:/var/run/dbus --volume /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket --volume /var/run/docker.sock:/var/run/docker.sock --volume $JETSON_REPO_PATH/data:/data --device /dev/snd --device /dev/bus/usb -e DISPLAY=:0 -v /tmp/.X11-unix/:/tmp/.X11-unix -v /tmp/.docker.xauth:/tmp/.docker.xauth -e XAUTHORITY=/tmp/.docker.xauth --device /dev/video0 --device /dev/video1 -v $JETSON_REPO_PATH/packages/llm/local_llm:/opt/local_llm/local_llm -e SSL_KEY=/data/key.pem -e SSL_CERT=/data/cert.pem dustynv/local_llm:r35.3.1 python3 -m local_llm.agents.video_query --api=mlc --verbose --model liuhaotian/llava-v1.5-7b --max-new-tokens 32 --video-input /dev/video0 --video-output webrtc://@:8554/output
|
445
|
+
;;
|
446
|
+
*)
|
447
|
+
echo "Unknown example"
|
448
|
+
# handle unknown
|
449
|
+
;;
|
450
|
+
esac
|
451
|
+
echo "----example done----"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jetson-examples
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.3
|
4
4
|
Summary: run AI on Jetson, all you need is reComputer
|
5
5
|
Author-email: luozhixin <zhixin.luo@seeed.cc>
|
6
6
|
Project-URL: Homepage, https://github.com/Seeed-Projects/jetson-examples
|
@@ -26,7 +26,7 @@ License-File: LICENSE
|
|
26
26
|
## Install
|
27
27
|
|
28
28
|
```sh
|
29
|
-
pip install
|
29
|
+
pip install jetson-examples
|
30
30
|
```
|
31
31
|
|
32
32
|
- [more installation methods](./docs/install.md)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
jetson_examples-0.0.3.data/data/scripts/run.sh,sha256=p_LSQExHx1YaCchu754NfNQSqTKeX8W--komUE_9vD4,16260
|
2
|
+
reComputer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
reComputer/main.py,sha256=K-ZpxttBOmEdLKyy6fIN8K4EMJ48dVIN88WvbWioB4Q,1109
|
4
|
+
jetson_examples-0.0.3.dist-info/LICENSE,sha256=ac_LOi8ChcJhymEfBulX98Y06wTI2IMcQnqCXZ5yay4,1066
|
5
|
+
jetson_examples-0.0.3.dist-info/METADATA,sha256=Xxa2f3JC2xQmPlkbQJ8DqvgSC8rgSTJpPs_AIakWipI,2751
|
6
|
+
jetson_examples-0.0.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
7
|
+
jetson_examples-0.0.3.dist-info/entry_points.txt,sha256=5-OdcBifoDjVXE9KjNoN6tQa8l_XSXhdbBEgL2hxeDM,58
|
8
|
+
jetson_examples-0.0.3.dist-info/top_level.txt,sha256=SI-liiUOkoGwOJfMP7d7k63JKgdcbiEj6DEC8QIKI90,11
|
9
|
+
jetson_examples-0.0.3.dist-info/RECORD,,
|
@@ -1,173 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
check_is_jetson_or_not() {
|
4
|
-
model_file="/proc/device-tree/model"
|
5
|
-
|
6
|
-
if [ -f "$model_file" ]; then
|
7
|
-
first_line=$(head -n 1 "$model_file")
|
8
|
-
|
9
|
-
if [[ "$first_line" == NVIDIA* ]]; then
|
10
|
-
echo "INFO: jetson machine confirmed..."
|
11
|
-
else
|
12
|
-
echo "WARNING: your machine maybe not support..."
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
else
|
16
|
-
echo "ERROR: only jetson support this..."
|
17
|
-
exit 1
|
18
|
-
fi
|
19
|
-
}
|
20
|
-
check_is_jetson_or_not
|
21
|
-
|
22
|
-
check_disk_space() {
|
23
|
-
directory="$1" # a directory
|
24
|
-
required_space_gb="$2" # how many GB we need
|
25
|
-
|
26
|
-
# get disk of directory
|
27
|
-
device=$(df -P "$directory" | awk 'NR==2 {print $1}')
|
28
|
-
echo $device
|
29
|
-
|
30
|
-
# get free space in KB
|
31
|
-
free_space=$(df -P "$device" | awk 'NR==2 {print $4}')
|
32
|
-
echo $free_space
|
33
|
-
|
34
|
-
# change unit to GB
|
35
|
-
free_space_gb=$(echo "scale=2; $free_space / 1024 / 1024" | bc)
|
36
|
-
echo $free_space_gb
|
37
|
-
|
38
|
-
# check and fast-fail
|
39
|
-
if (( $(echo "$free_space_gb >= $required_space_gb" | bc -l) )); then
|
40
|
-
echo "disk space ($1) enough, keep going."
|
41
|
-
else
|
42
|
-
echo "disk space ($1) not enough!! we need $2 GB!!"
|
43
|
-
exit 1
|
44
|
-
fi
|
45
|
-
}
|
46
|
-
|
47
|
-
echo "run example:$1"
|
48
|
-
BASE_PATH=/home/$USER/reComputer
|
49
|
-
echo "----example init----"
|
50
|
-
mkdir -p $BASE_PATH/
|
51
|
-
JETSON_REPO_PATH="$BASE_PATH/jetson-containers"
|
52
|
-
if [ -d $JETSON_REPO_PATH ]; then
|
53
|
-
echo "jetson-ai-lab existed."
|
54
|
-
else
|
55
|
-
echo "jetson-ai-lab does not installed. start init..."
|
56
|
-
cd $BASE_PATH/
|
57
|
-
git clone --depth=1 https://github.com/dusty-nv/jetson-containers
|
58
|
-
cd $JETSON_REPO_PATH
|
59
|
-
sudo apt update; sudo apt install -y python3-pip
|
60
|
-
pip3 install -r requirements.txt
|
61
|
-
fi
|
62
|
-
echo "----example start----"
|
63
|
-
cd $JETSON_REPO_PATH
|
64
|
-
case "$1" in
|
65
|
-
"llava")
|
66
|
-
./run.sh $(./autotag llava) \
|
67
|
-
python3 -m llava.serve.cli \
|
68
|
-
--model-path liuhaotian/llava-v1.5-7b \
|
69
|
-
--image-file /data/images/hoover.jpg
|
70
|
-
;;
|
71
|
-
"llava-v1.5-7b")
|
72
|
-
./run.sh $(./autotag llava) \
|
73
|
-
python3 -m llava.serve.cli \
|
74
|
-
--model-path liuhaotian/llava-v1.5-7b \
|
75
|
-
--image-file /data/images/hoover.jpg
|
76
|
-
;;
|
77
|
-
"llava-v1.6-vicuna-7b")
|
78
|
-
./run.sh $(./autotag local_llm) \
|
79
|
-
python3 -m local_llm --api=mlc \
|
80
|
-
--model liuhaotian/llava-v1.6-vicuna-7b \
|
81
|
-
--max-context-len 768 \
|
82
|
-
--max-new-tokens 128
|
83
|
-
;;
|
84
|
-
"Sheared-LLaMA-2.7B-ShareGPT")
|
85
|
-
./run.sh $(./autotag local_llm) \
|
86
|
-
python3 -m local_llm.chat --api=mlc \
|
87
|
-
--model princeton-nlp/Sheared-LLaMA-2.7B-ShareGPT
|
88
|
-
;;
|
89
|
-
"text-generation-webui")
|
90
|
-
# download llm model
|
91
|
-
./run.sh --workdir=/opt/text-generation-webui $(./autotag text-generation-webui) /bin/bash -c \
|
92
|
-
'python3 download-model.py --output=/data/models/text-generation-webui TheBloke/Llama-2-7b-Chat-GPTQ'
|
93
|
-
# run text-generation-webui
|
94
|
-
./run.sh $(./autotag text-generation-webui)
|
95
|
-
;;
|
96
|
-
"stable-diffusion-webui")
|
97
|
-
./run.sh $(./autotag stable-diffusion-webui)
|
98
|
-
;;
|
99
|
-
"nanoowl")
|
100
|
-
./run.sh $(./autotag nanoowl) bash -c "ls /dev/video* && cd examples/tree_demo && python3 tree_demo.py ../../data/owl_image_encoder_patch32.engine"
|
101
|
-
;;
|
102
|
-
"whisper")
|
103
|
-
./run.sh $(./autotag whisper)
|
104
|
-
;;
|
105
|
-
"nanodb")
|
106
|
-
# check data files TODO: support params to force download
|
107
|
-
DATA_PATH="$JETSON_REPO_PATH/data/datasets/coco/2017"
|
108
|
-
if [ ! -d $DATA_PATH ]; then
|
109
|
-
mkdir -p $DATA_PATH
|
110
|
-
fi
|
111
|
-
cd $DATA_PATH
|
112
|
-
# check val2017.zip
|
113
|
-
if [ ! -d "$DATA_PATH/val2017" ]; then
|
114
|
-
if [ ! -f "val2017.zip" ]; then
|
115
|
-
check_disk_space $DATA_PATH 1
|
116
|
-
wget http://images.cocodataset.org/zips/val2017.zip
|
117
|
-
else
|
118
|
-
echo "val2017.zip existed."
|
119
|
-
fi
|
120
|
-
check_disk_space $DATA_PATH 19
|
121
|
-
unzip val2017.zip && rm val2017.zip
|
122
|
-
else
|
123
|
-
echo "val2017/ existed."
|
124
|
-
fi
|
125
|
-
# check train2017.zip
|
126
|
-
if [ ! -d "$DATA_PATH/train2017" ]; then
|
127
|
-
if [ ! -f "train2017.zip" ]; then
|
128
|
-
check_disk_space $DATA_PATH 19
|
129
|
-
wget http://images.cocodataset.org/zips/train2017.zip
|
130
|
-
else
|
131
|
-
echo "train2017.zip existed."
|
132
|
-
fi
|
133
|
-
check_disk_space $DATA_PATH 19
|
134
|
-
unzip train2017.zip && rm train2017.zip
|
135
|
-
else
|
136
|
-
echo "train2017/ existed."
|
137
|
-
fi
|
138
|
-
if [ ! -d "$DATA_PATH/unlabeled2017" ]; then
|
139
|
-
# check unlabeled2017.zip
|
140
|
-
if [ ! -f "unlabeled2017.zip" ]; then
|
141
|
-
check_disk_space $DATA_PATH 19
|
142
|
-
wget http://images.cocodataset.org/zips/unlabeled2017.zip
|
143
|
-
else
|
144
|
-
echo "unlabeled2017.zip existed."
|
145
|
-
fi
|
146
|
-
check_disk_space $DATA_PATH 19
|
147
|
-
unzip unlabeled2017.zip && rm unlabeled2017.zip
|
148
|
-
else
|
149
|
-
echo "unlabeled2017/ existed."
|
150
|
-
fi
|
151
|
-
|
152
|
-
# check index files
|
153
|
-
INDEX_PATH="$JETSON_REPO_PATH/data/nanodb/coco/2017"
|
154
|
-
if [ ! -d $INDEX_PATH ]; then
|
155
|
-
cd $JETSON_REPO_PATH/data/
|
156
|
-
check_disk_space $JETSON_REPO_PATH 1
|
157
|
-
wget https://nvidia.box.com/shared/static/icw8qhgioyj4qsk832r4nj2p9olsxoci.gz -O nanodb_coco_2017.tar.gz
|
158
|
-
tar -xzvf nanodb_coco_2017.tar.gz
|
159
|
-
fi
|
160
|
-
|
161
|
-
# RUN
|
162
|
-
cd $JETSON_REPO_PATH
|
163
|
-
./run.sh $(./autotag nanodb) \
|
164
|
-
python3 -m nanodb \
|
165
|
-
--path /data/nanodb/coco/2017 \
|
166
|
-
--server --port=7860
|
167
|
-
;;
|
168
|
-
*)
|
169
|
-
echo "Unknown example"
|
170
|
-
# handle unknown
|
171
|
-
;;
|
172
|
-
esac
|
173
|
-
echo "----example done----"
|
@@ -1,9 +0,0 @@
|
|
1
|
-
jetson_examples-0.0.1.data/data/scripts/run.sh,sha256=URYwn-EKgLolwNorU-d_LlaZC925sYg7nZO-guOcAsQ,5617
|
2
|
-
reComputer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
reComputer/main.py,sha256=K-ZpxttBOmEdLKyy6fIN8K4EMJ48dVIN88WvbWioB4Q,1109
|
4
|
-
jetson_examples-0.0.1.dist-info/LICENSE,sha256=ac_LOi8ChcJhymEfBulX98Y06wTI2IMcQnqCXZ5yay4,1066
|
5
|
-
jetson_examples-0.0.1.dist-info/METADATA,sha256=K3QgJ1VeZ_wPKNc3Pb_GtGV4WoilakN8vbs8uHY9aX4,2746
|
6
|
-
jetson_examples-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
7
|
-
jetson_examples-0.0.1.dist-info/entry_points.txt,sha256=5-OdcBifoDjVXE9KjNoN6tQa8l_XSXhdbBEgL2hxeDM,58
|
8
|
-
jetson_examples-0.0.1.dist-info/top_level.txt,sha256=SI-liiUOkoGwOJfMP7d7k63JKgdcbiEj6DEC8QIKI90,11
|
9
|
-
jetson_examples-0.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|