Robotics StackExchange | Archived questions

How to import deep-learning libraries?

Hello there, I'm fairly new to ROS and robotics. I'd like to use a web camera to predict my surroundings in real time. I have the model weight, which I tested on a Jupyter notebook by feeding it with some images. Pytorch lighting (resulting .ckpt file) was used to train the model. My laptop will be connected via USB to a robot.

I made a ROS package that includes several Python scripts. However, I don't know how to import libraries from a specific script (others use widely used packages such as rospy, cvbridge, sensormsgs, and so on). When I searched for it on Google, the results were confusing and appeared to be quite complex.

At the very least, I know I need to add certain lines to CmakeLists.txt and package.xml.

I'd like to import the following libraries:

import cv2
import pytorch_lightning as pl
import torch
from PIL import Image
from torch import sigmoid
from torchvision import transforms
from transformers import (  
  AutoImageProcessor,
BeitForImageClassification,
ConvNextForImageClassification,
)

I just installed above libraries locally on my laptop without virtual env for ease, pardon me.

My system info is:

Ubuntu version: Ubuntu 20.04.6 LTS

ROS version: ROS1 noetic.

Please, help me.

Asked by Turuu on 2023-07-27 18:19:23 UTC

Comments

there is a ROS package called dodo_detector that uses tensorflow and python2. You may be able to get a good idea how to answer your questions by looking at how that package used tensorflow.

https://github.com/douglasrizzo/dodo_detector_ros

Asked by billy on 2023-07-27 18:30:29 UTC

Hey, I figured it out. But, someone else answered my question on reddit and solved my problem. Anyway, thank you for leaving a comment.

Asked by Turuu on 2023-08-02 11:56:57 UTC

Answers