ray-project / ray

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
33.43k stars 5.67k forks source link

Error in Ray Execution #5605

Closed guruvishnuvardan closed 4 years ago

guruvishnuvardan commented 5 years ago

Hi,

Please note, I am not seeing any output, Can you please let me know the reason

ioz@ioz-HP-Laptop-15-bs0xx:~/2019_07_13/CodeWrks$ python vel2.py
2019-08-31 19:13:00,528 WARNING worker.py:1373 -- WARNING: Not updating worker name since `setproctitle` is not installed. Install this with `pip install setproctitle` (or ray[debug]) to enable monitoring of worker processes.
2019-08-31 19:13:00,529 INFO node.py:498 -- Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-08-31_19-13-00_529146_6034/logs.
2019-08-31 19:13:00,653 INFO services.py:409 -- Waiting for redis server at 127.0.0.1:20532 to respond...
2019-08-31 19:13:00,794 INFO services.py:409 -- Waiting for redis server at 127.0.0.1:16821 to respond...
2019-08-31 19:13:00,801 INFO services.py:809 -- Starting Redis shard with 0.81 GB max memory.
2019-08-31 19:13:00,862 INFO node.py:512 -- Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-08-31_19-13-00_529146_6034/logs.
2019-08-31 19:13:00,864 WARNING services.py:1330 -- WARNING: The default object store size of 1.21 GB will use more than 50% of the available memory on this node (1.47 GB). Consider setting the object store memory manually to a smaller size to avoid memory contention with other applications.
2019-08-31 19:13:00,865 INFO services.py:1475 -- Starting the Plasma object store with 1.21 GB memory using /dev/shm.
ioz@ioz-HP-Laptop-15-bs0xx:~/2019_07_13/CodeWrks$ 

Please find the Code Snippet:

import logging
import os
import requests
import sched
import requests_cache
import time
from datetime import date
from datetime import timedelta
from imutils import contours
from skimage import measure
from threading import Thread
import json
import ray
ray.init()

requests_cache.install_cache('api_cache', backend='memory', expire_after=180)

try:
    import cv2 as cv
except ImportError:
    raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
                      'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')

@ray.remote
def Zoom(cv2Object, zoomSize):
    # Resizes the image/video frame to the specified amount of "zoomSize".
    # A zoomSize of "2", for example, will double the canvas size
    cv2Object = imutils.resize(cv2Object, width=(zoomSize * cv2Object.shape[1]))
    # center is simply half of the height & width (y/2,x/2)
    center = (cv2Object.shape[0]/2,cv2Object.shape[1]/2)
    # cropScale represents the top left corner of the cropped frame (y/x)
    cropScale = (center[0]/zoomSize, center[1]/zoomSize)
    # The image/video frame is cropped to the center with a size of the original picture
    # image[y1:y2,x1:x2] is used to iterate and grab a portion of an image
    # (y1,x1) is the top left corner and (y2,x1) is the bottom right corner of new cropped frame.
    #cv2Object = cv2Object[cropScale[0]:(center[0] + cropScale[0]), cropScale[1]:(center[1] + cropScale[1])]
    return cv2Object

@ray.remote
def sr():

    try:

        smsCount = 0
        inWidth = 600
        inHeight = 600
        WHRatio = inWidth / float(inHeight)
        inScaleFactor = 0.007843
        meanVal = 127.5
        firstFrame = None

        classNames = ('background',
                      'aeroplane', 'bicycle', 'bird', 'boat',
                      'bottle', 'bus', 'car', 'cat', 'chair',
                      'cow', 'diningtable', 'dog', 'horse',
                      'motorbike', 'person', 'pottedplant',
                      'sheep', 'sofa', 'train', 'tvmonitor')

        parser = argparse.ArgumentParser()
        parser.add_argument("--video", help="path to video file. If empty, camera's stream will be used")
        parser.add_argument("--prototxt", default="MobileNetSSD_deploy.prototxt",
                            help="path to caffe prototxt")
        parser.add_argument("-m", "--caffemodel", default="MobileNetSSD_deploy.caffemodel",
                            help="path to caffemodel file, download it here: "
                                 "https://github.com/chuanqi305/MobileNet-SSD/")
        parser.add_argument("--thr", default=0.5, help="confidence threshold to filter out weak detections")
        args = parser.parse_args()

        today = datetime.date.today()
        todayerr = today.isoformat()

        logging.basicConfig(level=logging.DEBUG, filename='exceptions_Cam01_' + str(todayerr) + '.txt')

        num = 0

        #fvs = VideoStream("rtsp://admin:Admin@123@192.168.1.14:554/cam/realmonitor?channel=7&subtype=0").start()
        #fvs = VideoStream("rtsp://admin:admin12345@192.168.1.195:554/unicat/c3/s1/live").start()

        saliency = None
        with open('URL.txt', 'r') as fobj:
            data = json.load(fobj)
        r = requests.get(data['ClientUrl'])
        res = json.loads(r.text)
        fgbg = cv.bgsegm.createBackgroundSubtractorMOG()
        for obj in res:
            if obj.get('camera_id') == str(data['cam_id']):
                print(obj.get('camera_url'))
                fvs = WebcamVideoStream(0).start()

Note: sr() is the function/method that executes the Caffe DNN Object detection Code,

OS: Ubuntu 16.04 Processor: Intel® Celeron(R) CPU N3060 @ 1.60GHz × 2 Memory:3.8 GiB

Can you please help me resolve the issue.

Thanks GURU

richardliaw commented 4 years ago

Closing because stale, but you should change:

@ray.remote
def sr():

to

if __name__ == "__main__"