PNet | Networking middleware for unity using Lidgren | HTTP library
kandi X-RAY | PNet Summary
kandi X-RAY | PNet Summary
=== Networking middleware for Unity using Lidgren, with a custom dedicated server.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PNet
PNet Key Features
PNet Examples and Code Snippets
Community Discussions
Trending Discussions on PNet
QUESTION
The example datalink channel creation code used in the "Ethernet echo server" example on pnet's main doc page includes this snippet:
...ANSWER
Answered 2021-Feb-07 at 14:23pnet is trying to open a raw socket which requires root permissions or the CAP_NET_RAW capability. That causes the Operation not permitted error. Running as root resolves the issue.
QUESTION
I'm trying to intercept (i.e. consume, and not capture) packets at the data-link layer with the rust library pnet
, however it doesn't seem to intercept them, just read them. I'm unsure whether it's my lack of understanding of networking or something else that is the cause
Here is the sample code:
...ANSWER
Answered 2021-Feb-01 at 10:47I'm afraid it does not depend on the programming language but on the operating system. As far as I know, packet-sockets can capture/emit frames but do not intercept them; this is the purpose of the firewall. A very long time ago, I used to experiment this; here is what I know about it.
It takes place in the firewall; you have to modprobe ip_queue
then add a rule to send packets to that queue iptables -A OUTPUT -o eth1 -j QUEUE
(adapt input/output/interface as needed).
Then you have to build and run in userspace a program which interacts with that queue and gives a verdict (ACCEPT/DROP) for every packet.
This is done in C with and
-lipq
; I don't know if you can easily do the equivalent in Rust.
By the way, maybe the best solution is not to rely on a userspace process giving the verdict but just on usual firewall rules (if the criterion for the verdict is not too complicated). There exist many modules and iptables options which enable many complex rules.
QUESTION
I am getting a runtime error that says inputs and weights must be on same. However I made sure that my model and input are on the same device yet I cannot get rid of the error. As far as I read, I know that my input data is not on GPU . Since, In this case image is an input so I tried img = torch.from_numpy(img).to(device)
and pred = model(img)[0].to(device
but no luck. Please let me know what can be done.
Here's the code:
...ANSWER
Answered 2021-Jan-09 at 13:09You need to send the input tensor to your device, not its result:
QUESTION
I've been experimenting recently with password protecting sockets in python and I've come across an issue.
When checking the clients input with the servers set password the server seems to think the set password isn't the same as the password input by the user.
My first script: server.py
...ANSWER
Answered 2020-Dec-24 at 06:05You are comapring UUID object with a string, thats why its returning false,
to check, put a print before comparing,
QUESTION
I'm trying this code to regenerate this function to plot a network based on this link work, I know some functions are deprecated, I replaced opts with theme, but I got error with theme_rect
...ANSWER
Answered 2020-Dec-18 at 02:38Perhaps you could rewrite the 'theme' section to something like this:
QUESTION
I have the following 2d array that I get/create from an external .txt file.
...ANSWER
Answered 2020-Nov-12 at 14:39So I finally figured this out by doing a "bubble sort". Here's how I implemented it. Hopefully this can help someone else who's having trouble finding any examples of sorting with 2d arrays by a specific column:
QUESTION
I'm following the torch_script_custom_classes in order to expose my C++ dll in Python. The bulk of the code that I have at the moment is as follows:
...ANSWER
Answered 2020-Sep-19 at 09:30The error is kind of misleading! all that was needed was to convert all return types from int
to int64_t
and that was it. All compiles just fine now!
QUESTION
I'm trying to build a Python extension using Pybind11, and I believe I set up all libs, linker related objects correctly. However I get this weird linker error! This is my example input
...ANSWER
Answered 2020-Sep-14 at 13:33OK, I made a silly mistake! it seems when defining the PYBIND11_MODULE
, the first name, and the name used in setup()
need to be the same as the source file, i.e. PythonManager_Pybind11.cpp
in my case. This why the linker was complaining about the actual object which was the main source file.
Making these changes, now everything builds just fine.
This is how it looks after these minor changes:
QUESTION
I am trying to run inference on a jit traced model in C++ and currently the output I get in Python is different than the output I get in C++.
Initially I thought this be caused by the jit model itself, but now I don't think so, as I spotted some small deviations in the input tensor in the C++ code. I believe I did everything as instructed by the documentation so that might as well show an issue in torch::from_blob
. I'm not sure!
Therefore in order to make sure which is the case, here are the snippets both in Python and C++ plus the sample input to test it.
Here is the sample image:
For Pytorch run the following snippet of code:
...ANSWER
Answered 2020-Aug-30 at 14:20Its being made clear that this is indeed an input issue and more specifically this is because the image is first read by PIL.Image.open
in Python and later changed into a numpy
array. If the image is read with OpenCV
, then, everything input-wise, is the same both in Python and C++.
However, in my specific case, using the OpenCV image results in a minor change in the final result. The only way this change/difference is minimized, is when I make the Opencv image grayscale and feed it to the network in which case, both the PIL input and opencv input have nearly identical output.
Here are the two example, the pil image is bgr and the opencv is in grayscale mode: you need to save them on disk and see that the are nearly identical (left is cv_image, right is pil_image):
However, if I simply don't convert the opencv image into grayscale mode (and back to bgr to get 3 channels), this is how it looks (left is cv_image and right is pil_image):
Update
This turned out to be again input related. the reason we had slight differences was due to the model being trained on rgb images and thus channels order mattered. When using PIL image, there were some conversions happening back and forth for different methods and thus it caused the whole thing to be a mess that you earlier read about above.
To cut a long story short, there was not any issue regarding the conversion from cv::Mat
into a torch::Tensor
or vice versa, the issue was in the way the images were created and fed to the network differently in Python and C++. When both Python and C++ backend, used OpenCV for dealing with images, their output and result matched 100%.
QUESTION
I am converting the MTCNN tensorflow into tensorflow tensorRT
When I run camera_test.py
I get this error FailedPreconditionError: Attempting to use uninitialized in Tensorflow
Traceback (most recent call last): File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value conv4_2/biases [[{{node conv4_2/biases/read}}]] [[{{node Squeeze_1}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "camera_test_trrt.py", line 48, in boxes_c,landmarks = mtcnn_detector.detect(image) File "../Detection/MtcnnDetector.py", line 371, in detect boxes, boxes_c, _ = self.detect_pnet(img) File "../Detection/MtcnnDetector.py", line 221, in detect_pnet cls_cls_map, reg = self.pnet_detector.predict(im_resized) File "../Detection/fcn_detector_trrt.py", line 56, in predict self.height_op: height}) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value conv4_2/biases [[node conv4_2/biases/read (defined at ../train_models/mtcnn_model.py:208) ]] [[node Squeeze_1 (defined at ../train_models/mtcnn_model.py:245) ]]
Caused by op 'conv4_2/biases/read', defined at: File "camera_test_trrt.py", line 23, in PNet = FcnDetector(P_Net, '/home/jetsonnano/Downloads/MTCNN-Tensorflow-master/test/p_output_graph_FP16.pb') File "../Detection/fcn_detector_trrt.py", line 23, in init self.cls_prob, self.bbox_pred, _ = net_factory(image_reshape, training=False) File "../train_models/mtcnn_model.py", line 208, in P_Net bbox_pred = slim.conv2d(net,num_outputs=4,kernel_size=[1,1],stride=1,scope='conv4_2',activation_fn=None) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args return func(*args, **current_args) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1158, in convolution2d conv_dims=2) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args return func(*args, **current_args) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1061, in convolution outputs = layer.apply(inputs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1227, in apply return self.call(inputs, *args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 530, in call outputs = super(Layer, self).call(inputs, *args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 538, in call self._maybe_build(inputs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1603, in _maybe_build self.build(input_shapes) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/keras/layers/convolutional.py", line 174, in build dtype=self.dtype) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 435, in add_weight getter=vs.get_variable) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 349, in add_weight aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 607, in _add_variable_with_custom_getter **kwargs_for_getter) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1479, in get_variable aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1220, in get_variable aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 530, in get_variable return custom_getter(**custom_getter_kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1753, in layer_variable_getter return _model_variable_getter(getter, *args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1744, in _model_variable_getter aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args return func(*args, **current_args) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 350, in model_variable aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args return func(*args, **current_args) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 277, in variable aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 499, in _true_getter aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 911, in _get_single_variable aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 213, in call return cls._variable_v1_call(*args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 176, in _variable_v1_call aggregation=aggregation) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 155, in previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 2495, in default_variable_creator expected_shape=expected_shape, import_scope=import_scope) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 217, in call return super(VariableMetaclass, cls).call(*args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 1395, in init constraint=constraint) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 1557, in _init_from_args self._snapshot = array_ops.identity(self._variable, name="read") File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper return target(*args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 81, in identity ret = gen_array_ops.identity(input, name=name) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3890, in identity "Identity", input=input, name=name) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/jetsonnano/.virtualenvs/jetsonnanotest/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in init self._traceback = tf_stack.extract_stack()
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value conv4_2/biases [[node conv4_2/biases/read (defined at ../train_models/mtcnn_model.py:208) ]] [[node Squeeze_1 (defined at ../train_models/mtcnn_model.py:245) ]]
how do i tf.global_variables_initializer
will sess.run
ANSWER
Answered 2020-Jan-01 at 06:20Just after the following line
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PNet
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page