728x90

출처

Node.js 설치

[bluesanta@localhost ~]$ cd ~
[bluesanta@localhost ~]$ curl -sL https://rpm.nodesource.com/setup_18.x -o nodesource_setup.sh
[bluesanta@localhost ~]$ sudo bash nodesource_setup.sh
   
2025-04-21 16:22:50 - Repository is configured and updated.
2025-04-21 16:22:50 - You can use N|solid Runtime as a node.js alternative
2025-04-21 16:22:50 - To install N|solid Runtime, run: dnf install nsolid -y
2025-04-21 16:22:50 - Run 'dnf install nodejs -y' to complete the installation.
[bluesanta@localhost ~]$ sudo dnf install nodejs openssl -y
[bluesanta@localhost ~]$ node --version
v18.20.8
[bluesanta@localhost ~]$ sudo npm install -g configurable-http-proxy

jupyterhub 설치

[bluesanta@localhost ~]$ su - 
[root@localhost ~]# pip3.11 install sudospawner

jupyterhub 관리자 계정 생성

[bluesanta@localhost ~]$ sudo groupadd jupyterhub
[bluesanta@localhost ~]$ sudo useradd -g jupyterhub -s /bin/bash -m jupyterhubapp

jupyterhub 관리자 계정 로그인

[bluesanta@localhost ~]$ su - jupyterhubapp
암호:
[jupyterhubapp@localhost ~]$ 

jupyterhub 실행

[jupyterhubapp@localhost ~]$ jupyterhub
[I 2025-04-21 16:59:44.638 JupyterHub app:3354] Running JupyterHub version 5.3.0
[I 2025-04-21 16:59:44.638 JupyterHub app:3384] Using Authenticator: jupyterhub.auth.PAMAuthenticator-5.3.0
[I 2025-04-21 16:59:44.638 JupyterHub app:3384] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-5.3.0
[I 2025-04-21 16:59:44.638 JupyterHub app:3384] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-5.3.0
   
[I 2025-04-21 16:59:44.987 JupyterHub proxy:477] Adding route for Hub: / => http://127.0.0.1:8081
16:59:44.988 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
16:59:44.988 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
16:59:44.989 [ConfigProxy] info: 201 POST /api/routes/ 
[I 2025-04-21 16:59:44.989 JupyterHub app:3778] JupyterHub is now running at http://:8000

jupyterhub_config.py 생성

[jupyterhubapp@localhost ~]$ cd /etc/jupyterhub/
[jupyterhubapp@localhost jupyterhub]$ jupyterhub --generate-config
Writing default config to: jupyterhub_config.py
[jupyterhubapp@localhost jupyterhub]$ ls
jupyterhub_config.py

jupyterhub 사용자 계정 만들기

[bluesanta@localhost ~]$ sudo useradd -g jupyterhub -s /bin/bash -m user01
[bluesanta@localhost ~]$ sudo passwd user01
user01 사용자의 비밀 번호 변경 중
새 암호:
새 암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.

jupyterhub_config.py 파일 수정

[bluesanta@localhost ~]$ sudo vi /etc/jupyterhub/jupyterhub_config.py
c.JupyterHub.hub_connect_ip = '0.0.0.0'
c.JupyterHub.port = 8000

c.Authenticator.whitelist = set({'user01'})
c.Authenticator.allow_all = True

c.PAMAuthenticator.admin_users = set({'jupyterhubapp'})
# c.PAMAuthenticator.admin_groups = set({'jupyterhub'})

jupyterhub 서비스 등록

jupyterhub.service 파일 생성

[bluesanta@localhost ~]$ sudo vi /etc/systemd/system/jupyterhub.service
[Unit]
Description=JupyterHub
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/jupyter.pid
User=root
WorkingDirectory=/etc/jupyterhub
ExecStart=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

[Install]
WantedBy=multi-user.target

jupyterhub 서비스 등록

[bluesanta@localhost ~]$ sudo systemctl enable jupyterhub.service 
Created symlink /etc/systemd/system/multi-user.target.wants/jupyterhub.service → /etc/systemd/system/jupyterhub.service.

jupyterhub 서비스 갱신

[bluesanta@localhost ~]$ sudo systemctl daemon-reload

8000 포트 개방

[bluesanta@localhost ~]$ sudo firewall-cmd --permanent --zone=public --add-port=8000/tcp
success
[bluesanta@localhost ~]$ sudo firewall-cmd --reload
success
728x90
728x90

구출처

OpenCV 패키지 설치

(venv) D:\workspace.python\cubotino>pip install opencv_python opencv_contrib_python_headless opencv_contrib_python opencv_python_headless numpy==1.26.4

main.py

import cv2

def detect_faces(image_path):
    # 이미지 파일을 로드합니다.
    image = cv2.imread(image_path)

    # 이미지를 회색으로 변환합니다. (얼굴 인식은 흑백 이미지에서 수행되므로)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    # 얼굴 인식을 위해 얼굴 검출기를 로드합니다.
    print(f'cv data path = {cv2.data.haarcascades}')
    face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

    # 이미지에서 얼굴을 검출합니다.
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))

    # 검출된 얼굴 주위에 사각형을 그립니다.
    for (x, y, w, h) in faces:
        cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)

    # 결과 이미지를 화면에 출력합니다.
    cv2.imshow('Face Detection', image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

# 얼굴을 인식할 이미지를 지정합니다.
image_path = 'face.jpg'

# 얼굴 인식 함수를 호출합니다.
detect_faces(image_path)

실행

D:\workspace.python\cubotino\venv\Scripts\python.exe D:\workspace.python\cubotino\main.py 
cv data path = D:\workspace.python\cubotino\venv\Lib\site-packages\cv2\data\

728x90
728x90

[File] > [New Project...] 메뉴 선택

실행 환경 설정

main.py 소스

# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

실행

상단에 Run 버튼 선택

실행 결과

D:\workspace.python\Example1\venv\Scripts\python.exe D:\workspace.python\Example1\main.py 
Hi, PyCharm
728x90

+ Recent posts