• 카테고리

    질문 & 답변
  • 세부 분야

    컴퓨터 비전

  • 해결 여부

    미해결

파이에베이스 설치 에러

20.09.06 16:07 작성 조회수 286

0

터미널로 파이어베이스 어드민 설치 후

전부 똑같이 실행했는데 저런 에러가 나오네요..

인터넷 뒤져봐도 없어서 그런데 혹시 왜 그런지 알 수 있을까요?

Traceback (most recent call last):

  File "/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/RBP_DL21_YOLO_car.py", line 75, in <module>

    import firebase_admin

ModuleNotFoundError: No module named 'firebase_admin'

>>> 

import cv2

import numpy as np

import time

min_confidence = 0.5

margin = 30

file_name = "/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/image/w.PNG"

# Load Yolo

net = cv2.dnn.readNet("/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/yolo/yolov3.weights", "/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/yolo/yolov3.cfg")

classes = []

with open("/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/yolo/coco.names", "r") as f:

    classes = [line.strip() for line in f.readlines()]

print(classes)

layer_names = net.getLayerNames()

output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]

# Loading image

start_time = time.time()

img = cv2.imread(file_name)

height, width, channels = img.shape

# Detecting objects

blob = cv2.dnn.blobFromImage(img, 0.00392, (416, 416), (0, 0, 0), True, crop=False)

net.setInput(blob)

outs = net.forward(output_layers)

# Showing informations on the screen

confidences = []

boxes = []

for out in outs:

    for detection in out:

        scores = detection[5:]

        class_id = np.argmax(scores)

        confidence = scores[class_id]

        # Filter only 'car'

        if class_id == 0 and confidence > min_confidence:

            # Object detected

            center_x = int(detection[0] * width)

            center_y = int(detection[1] * height)

            w = int(detection[2] * width)

            h = int(detection[3] * height)

            # Rectangle coordinates

            x = int(center_x - w / 2)

            y = int(center_y - h / 2)

            boxes.append([x, y, w, h])

            confidences.append(float(confidence))

indexes = cv2.dnn.NMSBoxes(boxes, confidences, min_confidence, 0.4)

font = cv2.FONT_HERSHEY_PLAIN

color = (0, 255, 0)

for i in range(len(boxes)):

    if i in indexes:

        x, y, w, h = boxes[i]

        label = '{:,.2%}'.format(confidences[i])

        print(i, label)

        cv2.rectangle(img, (x, y), (x + w, y + h), color, 2)

        cv2.putText(img, label, (x, y - 10), font, 1, color, 2)

        

text = "Number of woohayoun is : {} ".format(len(indexes))

cv2.putText(img, text, (margin, margin), font, 2, color, 2)

cv2.imshow("Number of Car - "+file_name, img)

end_time = time.time()

process_time = end_time - start_time

print("=== A frame took {:.3f} seconds".format(process_time))

# https://firebase.google.com/docs/admin/setup#prerequisites

# https://firebase.google.com/docs/database/admin/start

import firebase_admin

from firebase_admin import credentials

from firebase_admin import db

from firebase_admin import storage

# Fetch the service account key JSON file contents

cred = credentials.Certificate('/Users/usang-in/끼리끼리 Dropbox/우상인/study/라즈베리파이/rbp_dnn/firepetstore-woo-firebase-adminsdk-c9bs8-5d126e4c51.json')

# Initialize the app with a service account, granting admin privileges

firebase_admin.initialize_app(cred, {

    'databaseURL': 'https://firepetstore-woo.firebaseio.com/',

    'storageBucket': 'gs://firepetstore-woo.appspot.com/'

})

bucket = storage.bucket()

blob = bucket.blob(file_name)

#blob.upload_from_filename(

#        file_name,

#        content_type='image/jpg'

#    )

blob.upload_from_filename(file_name)

ref = db.reference('parking')

box_ref = ref.child('west-coast')

box_ref.update({

    'count': len(indexes),

    'time': time.time(),

    'image': blob.public_url

})

cv2.waitKey(0)

cv2.destroyAllWindows()

답변 2

·

답변을 작성해보세요.

0

Woo  Sangin님의 프로필

Woo Sangin

질문자

2020.10.07

이건 터미널에서 설치할 떄 쓰는거 아닌가요..

제 생각에는

 'databaseURL': 'https://please-7e966.firebaseio.com/',

    'storageBucket': 'please-7e966.appspot.com/''

storagebucket 주소가 잘못된게 아닌가 싶은데 왜 그럴까요..

0

안녕하세요? 

모듈이름을 잘못 쓰신 것 같네요. 아래와 같이 써서 실행해보세요.

감사합니다.

import firebase-admin