inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[라즈베리파이] IoT 딥러닝 Computer Vision 실전 프로젝트

파이썬 파이어베이스 Admin 설정하기

파이에베이스 설치 에러

481

Woo Sangin

작성한 질문수 21

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()

keras 딥러닝 컴퓨터-비전 iot tensorflow Raspberry-Pi

답변 2

0

Woo Sangin

import firebase-admin

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

제 생각에는

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

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

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

0

노마드크리에이터

안녕하세요? 

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

감사합니다.

import firebase-admin

RBP_DL01_Raspberry pi inatall 문서 다운로드위치는?

0

72

1

강의 자료 다운관련 문의 드립니다.

0

130

1

강의자료를 크리애플 홈페이지에서 찾을 수 없네요..

0

374

1

64bit picamera 관련 질문

0

892

1

라즈베리파이 firebase 설치오류

0

537

0

도와주세요

0

341

1

64비트에서는 안되는건가요?

0

308

1

코드 크리애플 홈피에 없는데 어디있나요

0

382

1

답변 부탁드려요.

0

242

1

자료 강의 구매해야하던데, 답변 부탁드려요

0

325

0

현재 인프런에서 강의 듣고 있는데 자료가 없습니다. 자료 공유관련 답변 부탁드립니다.

0

341

2

라즈베리파이 hdmi 케이블

0

465

1

안녕하세요 크리애플 구독관련해서 질문드립니다.

0

213

0

강의 업데이트 부탁드립니다. 텐서플로워 설치가 안됩니다.

2

440

1

pygame 설치 오류

0

449

0

소스코드 다운 받으려면 결제를 해야 하나요?

0

204

1

얼굴 인식 정확도

0

299

1

import dropbox 오류

0

204

1

conda install -c conda-forgo dlib 오류

0

386

1

라즈베리파이에서 RBP_DL21_YOLO_car.py 실행시

0

219

1

주차장차량세기 picamera

0

218

1

강의와 다른 라즈베리파이 홈페이지

0

340

1

ModuleNotFoundError: No module named 'cv2' (해결)

0

6068

2

no module named 'cv2'

0

755

4