TimHsuTW
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 如何在TS-253B使用AWS Greengrass ML ## 準備工作 1. 準備USB WebCam並接上NAS 2. 請先完成AWS Greengrass基本設定,參考此教學文章 : [如何在 QNAP NAS 設定 AWS Greengrass](https://www.qnap.com/zh-tw/how-to/tutorial/article/%E5%A6%82%E4%BD%95%E5%9C%A8-qnap-nas-%E8%A8%AD%E5%AE%9A-aws-greengrass/) ## 安裝MXNet 1. 參照[AWS Greengrass ML文件 : https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html](https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html)步驟二下載MXNet Intel平台軟體,上傳至NAS Public資料夾: ![](https://i.imgur.com/xfRFken.png) 2. SSH進入NAS,移動安裝檔並解壓縮(依據安裝磁碟區不同路徑可能也會有所不同) ```bash cd /share/CACHEDEV1_DATA/.qpkg/Greengrass/package/greengrass mv /share/Public/ggc-mxnet-v1.2.1-python-intel.tar . tar -xzf ggc-mxnet-v1.2.1-python-intel.tar ``` 3. 進入Greengrass Container安裝MXNet ```bash system-docker exec -ti greengrass bash cd greengrass/ggc-mxnet-v1.2.1-python-intel/ apt update && apt install sudo unzip ./mxnet_installer.sh -u ``` ## 執行範例 ### 編輯範例程式 1. 參照[AWS Greengrass ML文件](https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html)步驟二下載MXNet Raspberry平台(執行範例會用到)軟體 2. 解壓縮`ggc-mxnet-v1.2.1-python-raspi.tar.gz`,在解壓縮`greengrass-ml-squeezenet-object-classification-raspi-python.tar.gz` 3. 編輯`load_model.py`,將底下註釋掉 : ```python=2.7 ''' #Captures an image from the PiCamera, then sends it for prediction def predict_from_cam(self, capfile='cap.jpg', reshape=(224, 224), N=5): if self.camera is None: self.camera = picamera.PiCamera() stream = io.BytesIO() self.camera.start_preview() time.sleep(2) self.camera.capture(stream, format='jpeg') # Construct a numpy array from the stream data = np.fromstring(stream.getvalue(), dtype=np.uint8) # "Decode" the image from the array, preserving colour image = cv2.imdecode(data, 1) return self.predict_from_image(image, reshape, N) ''' ``` 並新增 : ```python=2.7 #Captures an image from the webcam, then sends it for prediction def predict_from_webcam(self, capfile='cap.jpg', reshape=(224, 224), N=5): print "capture.......\n" cap = cv2.VideoCapture(0) flag, image = cap.read() print "read.......\n" return self.predict_from_image(image, reshape, N) ``` 完成後儲存 4. 參照[AWS Greengrass ML文件](https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html)步驟五建立Lambda Function ### 編輯Greengrass Group 1. 在**Group**設定頁面上,選擇**Resource** 2. 在**Local Resources**選項中,選擇**Add local resource** 3. 在**Create a local resource**頁面上,使用以下值: | Property | Value | | -------- | -------- | | Resource name | video | | Resource type | Device | | Device path | /dev/video0 | | Group owner file access permission | Automatically add OS group permissions of the Linux group that owns the resource| ![](https://i.imgur.com/BILo0DH.png) 4. 在**Lambda function affiliations**下,點擊**Select**,選擇**greengrassObjectClassification**,選擇**Read and write access**訪問權限,然後點擊**Done** ![](https://i.imgur.com/shJ4Tpd.png) 5. 剩下上傳model步驟參考[AWS Greengrass ML文件](https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html) **uploading the squeezenet.zip model package to Amazon S3.** 段落操作 6. 設定Subscription跟Deploy也請參考:[AWS Greengrass ML文件](https://docs.aws.amazon.com/greengrass/latest/developerguide/ml-console.html)步驟8、9,以及後續測試步驟 ![](https://i.imgur.com/rEkSB25.png) ## (其他)設定AWS Greengrass停止重啟MXNet Library資料不會被移除 預設只要在NAS重開機或是在App Center停止後,Greengrass Container就會被刪除,暫時不被刪除方法請參考如下步驟 : 1. 修改`/share/CACHEDEV1_DATA/.qpkg/Greengrass/Greengrass.sh`檔案(依據安裝磁碟區不同路徑可能也會有所不同) : * 將Start區間的這行: ```bash COMPOSE_HTTP_TIMEOUT=300 ${DOCKER_COMPOSE} -p $PROJECT_NAME -f $QPKG_PATH/docker-compose.yml up -d >> $QPKG_PATH/compose.log 2>&1 ``` 改成 : ```bash COMPOSE_HTTP_TIMEOUT=300 ${DOCKER_COMPOSE} -p $PROJECT_NAME -f $QPKG_PATH/docker-compose.yml up --no-recreate -d >> $QPKG_PATH/compose.log 2>&1 ``` * 以及Stop區間這行 : ```bash COMPOSE_HTTP_TIMEOUT=300 $DOCKER_COMPOSE -p $PROJECT_NAME -f $QPKG_PATH/docker-compose.yml down >> $QPKG_PATH/compose_down.log 2>&1 ``` 改成 : ```bash COMPOSE_HTTP_TIMEOUT=300 $DOCKER_COMPOSE -p $PROJECT_NAME -f $QPKG_PATH/docker-compose.yml stop >> $QPKG_PATH/compose_down.log 2>&1 ``` 2. 保存後即可 ###### tags: `Tutorial`

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully