Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
My Eyes-Blind Person Assistive System
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-23-167
My Eyes-Blind Person Assistive System
Commits
38997c3f
Commit
38997c3f
authored
Sep 07, 2023
by
W.R.Ashini Kaushalya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inference.ipynb
parent
c00d76cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
39 deletions
+124
-39
inference__1_.ipynb
inference__1_.ipynb
+124
-39
No files found.
inference__1_.ipynb
View file @
38997c3f
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
23
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 2
4
,
"metadata": {},
"outputs": [
{
...
...
@@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
25
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -131,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
26
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -168,8 +168,9 @@
" for box, _, _ in zip(boxes, scores, labels):\n",
" xmin, ymin, xmax, ymax = box\n",
" roi_item = image_np[int(ymin):int(ymax), int(xmin):int(xmax)]\n",
" quality = inference_quality(roi_item)\n",
" item = inference_item(roi_item)\n",
" quality = inference_quality(roi_item)\n",
"\n",
" output.append({\n",
" \"item\": item,\n",
" \"quality\": quality,\n",
...
...
@@ -179,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
27
,
"metadata": {},
"outputs": [
{
...
...
@@ -189,7 +190,7 @@
" {'item': 'apple', 'quality': 'Rotten'}]"
]
},
"execution_count":
5
,
"execution_count":
27
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -201,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
28
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -212,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count":
16
,
"execution_count":
29
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -231,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count":
4
0,
"execution_count":
3
0,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -278,9 +279,61 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
31
,
"metadata": {},
"outputs": [],
"source": [
"# while True:\n",
"# if ref_node_cart.get() is not None:\n",
"# data_cart = ref_node_cart.get()\n",
"# print(data_cart)\n",
"# data_cart = data_cart['products']\n",
"# data_cart = list(data_cart.values())\n",
" \n",
"# cart_details = {}\n",
"# for item in data_cart:\n",
"# item_name = item['name'].strip().lower()\n",
"# quantity = item['qty']\n",
"\n",
"# if item_name not in cart_details:\n",
"# cart_details[item_name] = quantity\n",
"\n",
"# cap = cv.VideoCapture(0)\n",
"# while True:\n",
"# cart_details_cp = cart_details.copy() \n",
"# for i in range(cart_details_cp[item]):\n",
"# while cart_details_cp[item] > 0:\n",
"\n",
"# break \n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"from matplotlib import pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'apple': 3, 'grape': 1}\n",
"selected apple is Fresh\n",
"selected apple is Fresh\n",
"selected grape is Fresh\n",
"selected grape is Fresh\n"
]
}
],
"source": [
"while True:\n",
" if ref_node_cart.get() is not None:\n",
...
...
@@ -295,43 +348,75 @@
"\n",
" if item_name not in cart_details:\n",
" cart_details[item_name] = quantity\n",
"\n",
"
print(cart_details)
\n",
" cap = cv.VideoCapture(0)\n",
" while True:\n",
" cart_details_cp = cart_details.copy()\n",
" for i in range(quantity):\n",
" while cart_details_cp[item] > 0:\n",
"\n",
" image = cap.read()[1]\n",
" image = cv.cvtColor(image, cv.COLOR_BGR2RGB)\n",
" cv.imwrite('tmp.jpg', image)\n",
"\n",
" output = process_objects('tmp.jpg')\n",
"\n",
" if len(output) > 0:\n",
" for o in output:\n",
" item = o['item']\n",
" quality = o['quality']\n",
" if quality == \"Fresh\":\n",
" cart_details_cp[item] -= 1\n",
" speech_string = f\"selected {item} is {quality}\"\n",
" print(speech_string)\n",
"\n",
" # update speech in ref_node_blind_voice node\n",
" ref_node_blind_voice.update({\n",
" 'speech': speech_string,\n",
" 'location' : ref_node_blind_voice.get()['location']\n",
" })\n",
" for item, quantity in cart_details_cp.items():\n",
" for i in range(cart_details_cp[item]):\n",
" while cart_details_cp[item] > 0:\n",
"\n",
" image = cap.read()[1]\n",
" # image = cv.cvtColor(image, cv.COLOR_BGR2RGB)\n",
" cv.imwrite('tmp.jpg', image)\n",
"\n",
" # plt.imshow(image)\n",
" # plt.show() \n",
"\n",
" cv2.imshow(\"CART\", image)\n",
"\n",
" k = cv2.waitKey(1)\n",
" if k%256 == 27:\n",
" print(\"Escape hit, closing...\")\n",
" break \n",
"\n",
" try:\n",
" output = process_objects('tmp.jpg')\n",
" except:\n",
" pass\n",
"\n",
" if len(output) > 0:\n",
" for o in output:\n",
" item_det = o['item']\n",
" quality_det = o['quality']\n",
" \n",
" if item_det in cart_details_cp:\n",
" if quality_det == \"Fresh\":\n",
" cart_details_cp[item] -= 1\n",
" speech_string = f\"selected {item_det} is {quality_det}\"\n",
" print(speech_string)\n",
"\n",
" # update speech in ref_node_blind_voice node\n",
" ref_node_blind_voice.update({\n",
" 'speech': speech_string,\n",
" 'location' : ref_node_blind_voice.get()['location']\n",
" })\n",
" \n",
"\n",
" for item, quantity in cart_details_cp.items(): \n",
" if quantity == 0:\n",
" del cart_details
_cp
[item]\n",
" del cart_details[item]\n",
"\n",
" if len(cart_details
_cp
) == 0:\n",
" if len(cart_details) == 0:\n",
" ref_node_cart.delete()\n",
" break"
" break\n",
"\n",
" cv2.destroyAllWindows()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
...
...
@@ -350,7 +435,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1
3
"
"version": "3.8.1
7
"
},
"orig_nbformat": 4
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment