Tensorflow Object Detection API - Do something when an object is detected - object

Hi I'm currently searching for studies or tutorials where they used tensorflow API to do something (alarm, save video, print something, etc.) when a certain object is detected. I don't know if I'm bad at using google cause I can't seem to find what I want. Hope you guys can give me links regarding this. Thanks in advance :)

go into the visualize_utils.py in the utils folder under the current model directory and start tweaking with it.
if you want to tweak with perse print something if you detect an object whose label is already known, you may want to do the following under
def visualize_boxes_and_labels_on_image_array(.....):
Say if you want to print the current object to python command line modify the following section of above mention method as follows
else:
if not agnostic_mode:
if classes[i] in category_index.keys():
class_name = category_index[classes[i]]['name']
if (class_name == 'person'):
print(class_name + "Detected")
Please correct me / add upon to my answer ! Thanks and Welcome in advance!

The method draw_bounding_box_on_image - Line 131 which draws bounding box for each detected object. You can call another methods to manipulate the detected object etc. inside of draw_bounding_box_on_image method.

https://www.tensorflow.org/tutorials/
here you go
This will help i guess

Related

Can multiple object attributes be patched at the same time?

I am looking to reduce nesting in my tests, I was looking at with patch.multiple() for the likes of below, but can't figure out a way to get it to work.
Where mock_task_instance, mock_dag_run and success_mock_task_instance are defined in the test function.
So I was wondering if there is a way that multiple object attributes be patched at the same time?
with patch.object(
mock_task_instance, "xcom_pull", side_effect=[self.file_name, self.config]
):
with patch.object(
mock_dag_run, "get_task_instances", return_value=[success_mock_task_instance]
):
with patch.object(
success_mock_task_instance, "current_state", return_value=State.SUCCESS
):
_my_func()
If you are looking for a way to cleanup nested with blocks, I recommend checking out contextlib.ExitStack() as this can help with than.
Here is the example from the docs:
with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]
# All opened files will automatically be closed at the end of
# the with statement, even if attempts to open files later
# in the list raise an exception
See: https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack
For your code, I think that might look a bit like:
with contextlib.ExitStack() as stack:
stack.enter_context(patch.object(mock_task_instance, "xcom_pull", side_effect=[self.file_name, self.config]))
stack.enter_context(patch.object(mock_dag_run, "get_task_instances", return_value=[success_mock_task_instance]))
stack.enter_context(patch.object(success_mock_task_instance, "current_state", return_value=State.SUCCESS))
_my_func()

Pressing a key down using the function node

I have set up a simple line of code, and I would like to try to press a key, for example "w", down whenever a integer between 1 and 10 is detected. I am relatively new to node-red and dont have much knowledge. i've searched around a bit but cannot find any answers to my question, any help would be greatly apreciated!
There looks to be 2 nodes in the library (on https://flows.nodered.org) that might be able to do what you want.
https://flows.nodered.org/node/node-red-contrib-autokey
https://flows.nodered.org/node/node-red-contrib-sendkeys
Unfortunately there doesn't seem to be any documentation for either.
After quick look at code the first (node-red-contrib-autokey) it looks to use robotjs and if you include /key in the msg.topic it will then "press" the key found in msg.payload.key
Details of key names can be found here https://robotjs.io/docs/syntax#keys

2 Sequential Transactions, setting Detail Number (Revit API / Python)

Currently, I made a tool to rename view numbers (“Detail Number”) on a sheet based on their location on the sheet. Where this is breaking is the transactions. Im trying to do two transactions sequentially in Revit Python Shell. I also did this originally in dynamo, and that had a similar fail , so I know its something to do with transactions.
Transaction #1: Add a suffix (“-x”) to each detail number to ensure the new numbers won’t conflict (1 will be 1-x, 4 will be 4-x, etc)
Transaction #2: Change detail numbers with calculated new number based on viewport location (1-x will be 3, 4-x will be 2, etc)
Better visual explanation here: https://www.docdroid.net/EP1K9Di/161115-viewport-diagram-.pdf.html
Py File here: http://pastebin.com/7PyWA0gV
Attached is the python file, but essentially what im trying to do is:
# <---- Make unique numbers
t = Transaction(doc, 'Rename Detail Numbers')
t.Start()
for i, viewport in enumerate(viewports):
setParam(viewport, "Detail Number",getParam(viewport,"Detail Number")+"x")
t.Commit()
# <---- Do the thang
t2 = Transaction(doc, 'Rename Detail Numbers')
t2.Start()
for i, viewport in enumerate(viewports):
setParam(viewport, "Detail Number",detailViewNumberData[i])
t2.Commit()
Attached is py file
As I explained in my answer to your comment in the Revit API discussion forum, the behaviour you describe may well be caused by a need to regenerate between the transactions. The first modification does something, and the model needs to be regenerated before the modifications take full effect and are reflected in the parameter values that you query in the second transaction. You are accessing stale data. The Building Coder provides all the nitty gritty details and numerous examples on the need to regenerate.
Summary of this entire thread including both problems addressed:
http://thebuildingcoder.typepad.com/blog/2016/12/need-for-regen-and-parameter-display-name-confusion.html
So this issue actually had nothing to do with transactions or doc regeneration. I discovered (with some help :) ), that the problem lied in how I was setting/getting the parameter. "Detail Number", like a lot of parameters, has duplicate versions that share the same descriptive param Name in a viewport element.
Apparently the reason for this might be legacy issues, though im not sure. Thus, when I was trying to get/set detail number, it was somehow grabbing the incorrect read-only parameter occasionally, one that is called "VIEWER_DETAIL_NUMBER" as its builtIn Enumeration. The correct one is called "VIEWPORT_DETAIL_NUMBER". This was happening because I was trying to get the param just by passing the descriptive param name "Detail Number".Revising how i get/set parameters via builtIn enum resolved this issue. See images below.
Please see pdf for visual explanation: https://www.docdroid.net/WbAHBGj/161206-detail-number.pdf.html

export data from gams to excel

I have a mathematical model and I want to run it 10 times automatically with different data sets which are generated randomly(when the first model stops, start another model automatically). for this purpose I have written the solve statement in a loop . I want to see the result of these 10 models in different sheets of an excel file. how can I do it? is it possible to correct my code?
set k/sheet1*sheet10/;
loop(k,
data generation....
solve statement....
execute_unload 'RESULT.gdx'
execute 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx var=x.l rng='k.t1:0'!a1'
);
I really appreciate your kind helps
Actually, you are pretty close already, you just need to use 'put_utility' instead of 'execute' to make use of the 'k.tl' syntax (note: it is .tl, not .t1):
*dummy put file
file fx; put fx;
set k/sheet1*sheet10/;
loop(k,
solve statement....
execute_unload 'RESULT.gdx'
put_utility 'exec' / 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx var=x.l rng='k.tl:0'!a1';
);
I hope that helps!
Best regards,
Lutz

modx Decrement a TV to obtain 0

I need my [[+idx]] tv to start at 0 instead of 1 so I tried this:
[[+idx:decr]] or [[+idx:substract=1]] but it gives me -1 (minus one).
Does anyone know another way to obtain 0?
Thank you
Using this in chunk for getImageList works (at least for me):
[[+idx:decr]]
It gives: 0,1,2,3 ....
P.S. using modx revo 2.3.1
set your template variable default to 0 when you create the variable.
What are you trying to do, your question is vague at best.
UPDATE
ok - what I think will work for you is to write a snippet to do the math... where ever you call the [[+idx]] instead write a snippet
[[!FixIDX? &itemindex=`[[+idx]]`]]
then in your FixIDX snippet just do the math with php and return the corrected index. Though perhaps a custom output modifier would be the better way to go: http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+(Output+Modifiers)
Though looking at the docs, your code should certainly work - I see no reason for it not to.

Resources