Giter VIP home page Giter VIP logo

tensorflow-2-object-counting's Introduction

Hi πŸ‘‹, I'm Gilbert Tanner

I'm a software engineer from Austria currently studying Robotics and Artificial Intelligence at the University of Klagenfurt.

  • πŸ‘¨πŸ½β€πŸ’» Currently working and growing my skillset in Robotics and Artificial Intelligence
  • 🀝 Open for collaborations regarding technical articles and Machine Learning projects
  • 🌐 Visit my website for more information

πŸ“• Latest Blog Posts

🀝Connect with me:

tensorflow-2-object-counting's People

Contributors

dependabot[bot] avatar tannergilbert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow-2-object-counting's Issues

Move line to y axis

How can i move line to y axis from x axis?which command do this operation?

Tflite IndexError: list index out of range

When i use tflite model which is converted from darknet yolov4 weights i get this error,its quantized float16 tflite model,and i use only one class for my model
How can i fix this?
thanks in advance

C:\Users\Erkin\Desktop\tf yolov4\Tensorflow-2-Object-Counting>python tflite_cumulative_object_counting.py -m model.tflite -l labelmap.txt -v video.mp4 -a
Traceback (most recent call last):
  File "tflite_cumulative_object_counting.py", line 228, in <module>
    main()
  File "tflite_cumulative_object_counting.py", line 137, in main
    results = detect_objects(interpreter, image_pred, args.threshold)
  File "tflite_cumulative_object_counting.py", line 49, in detect_objects
    scores = get_output_tensor(interpreter, 2)
  File "tflite_cumulative_object_counting.py", line 36, in get_output_tensor
    output_details = interpreter.get_output_details()[index]
IndexError: list index out of range

Video, model and label map

Could you please provide a link to the video, model and label map that you used to generate examples? I would like to reproduce your results

Have you ever counted all detected object in a video and print out the total of all object in video?

I've a video of 3 minutes, and in that video I have 10-15 different object that can be detected using my model.

I can get the total of the object in one frame, but I would like to increment each time a new object detect.

for example in the first 30 seconds 3 persons detect, and then after 15 seconds another 2 persons detect, I would like to sum up this into totalcount = 5 persons and save into csv files etc.

those few lines of the code would count the detect object continuously but i would like to increment each object that counted.
final_count = [] filescore = np.squeeze(scores) count = 0 for i in range(100): if scores is None or filescore[i] > 0.5: count = count + 1 final_count.append(count) ymin = int(max(1,(boxes[i][0] * imH))) xmin = int(max(1,(boxes[i][1] * imW))) ymax = int(min(imH,(boxes[i][2] * imH))) xmax = int(min(imW,(boxes[i][3] * imW)))

            cv2.rectangle(frame, (xmin,ymin), (xmax,ymax), (10, 255, 0), 2)
            # Draw label                
            object_name = category_index[int(classes[i])]['name'] # Look up object name from "labels" array using class index
            label = '%s: %d%%' % (object_name, int(scores[i]*100)) # Example: 'person: 72%'

            labelSize, baseLine = cv2.getTextSize(label, cv2.FONT_HERSHEY_SIMPLEX, 0.7, 2) # Get font size
            label_ymin = max(ymin, labelSize[1] + 10) # Make sure not to draw label too close to top of window
            cv2.rectangle(frame, (xmin, label_ymin-labelSize[1]-10), (xmin+labelSize[0], label_ymin+baseLine-10), (255, 255, 255), cv2.FILLED) # Draw white box to put label text in
            cv2.putText(frame, label, (xmin, label_ymin-7), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2) # Draw label text
            
    
    if(len(new_name)> 0):     
        cv2.putText (frame,'Total Detections : ' + str(count),(10,25),cv2.FONT_HERSHEY_SIMPLEX,1,(70,235,52),2,cv2.LINE_AA)
     
    cv2.imshow("loading videos", frame)
    #print('These are total', total_object)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break`
        
      I tried both way. but I didnt get how I can increment each object that has been detect it. 

I tried using this one too ahmetozlu real time counting mode as well, but i just to increate all detect object into one total. let me know if you have tried this method.

Error Interpreter Wrapper

Hello, I hope it's not to late to ask you about something. I am an absolute beginner and I try to follow your great tutorial.
Everything went well running the code on tensorflow but when I tried to use tensorflow lite version these error appears :
ImportError: generic_type: type "InterpreterWrapper" is already registered!

I am working with tensorflow 2.5.1 and I didn't find any solution on web, sorry to disturb you maybe you experiment this?
Maybe it's about dependencies for tflite?

Thank you for your time

TypeError: only size-1 arrays can be converted to Python scalars

Hello Tanner,

I have tested saved_model (created by exporter_main_v2.py file), works very nice. And I created a new saved_model in order to create tflite model with export_tflite_graph_tf2.py (when I converted tflite from the previously saved model gives error: tflight Didn't find op for builtin opcode 'STRIDED_SLICE' version '6')

So far tflite model loaded with succes but this time bellow error gives at count:

File "tflite_cumulative_object_counting.py", line 83, in detect_objects
    count = int(get_output_tensor(interpreter, 3))
TypeError: only size-1 arrays can be converted to Python scalars

the returning value at line 83 is an array. ([0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]) so, giving error is int([0. 0. 0. 0. 0. 0. 0. 0. 0. 0.])

Actually, it is a Python error apart from TF. But I just wanted to get your opinion on how to solve this in a clever way.

Thanks in advance.

tflite_runtime==2.5.0

ERROR: Could not find a version that satisfies the requirement tflite_runtime==2.5.0 (from -r requirements.txt (line 5)) (from versions: none)
ERROR: No matching distribution found for tflite_runtime==2.5.0 (from -r requirements.txt (line 5))

Can not install this package for some reason. Does anyone know how to solve this?
My python version is 3.8.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.