본문 바로가기

python305

코랩에서 스테이블 디퓨전 사용해 보기 colab stable diffusion text2image 코랩에서 스테이블 디퓨전 사용해 보기 - colab stable diffusion, text2image¶아래 그림과 같이 매뉴에서 런타임 클릭 후 T4 GPU 사용을 설정해주세요In [1]: # Colab에 필요한 라이브러리 설치하기.!pip install --upgrade diffusers accelerate transformers In [2]: # 모델 불러오기from diffusers import DiffusionPipelinepipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") In [ ]: ## gpu에 모델 올리기pipeline.to("cuda") .. 2024. 9. 29.
파이썬 랜덤 이름, 랜덤 주소 만들기 (가짜이름, 가짜 주소 만들기) 파이썬 랜덤 이름, 랜덤 주소 만들기 (가짜이름, 가짜 주소 만들기)¶faker 패키지 설치In [1]: !pip install faker In [2]: # Faker 메서드 불러오고 객체 선언from faker import Fakerfake_class = Faker('ko-KR') In [3]: # 랜덤 이름 만들기fake_class.name() Out[3]:'박준서'In [4]: # 랜덤 이름 10개 만들기for _ in range(10): print(fake_class.name()) 조건우우영자이아름신정웅박민서김현우이영진이지아한보람김시우In [5]: # 랜덤 주소 만들기fake_class.address.. 2024. 9. 23.
01 주피터 노트북에서 파이썬으로 sql 태스트 환경 만들기¶ 01 주피터 노트북에서 파이썬으로 sql 태스트 환경 만들기¶sql 코딩테스트를 준비하기 위해 DB룰 설치하고 heidi SQL 등을 설치하고, DB를 만드는 과정이 번거롭다고 느끼면 아래와 같이 해보세요!단, 파이썬 코드에 익숙해야 유리합니다.In [1]: # sqlite3 패키지를 활용하여 example.db 만들기import sqlite3conn = sqlite3.connect('example.db')cursor = conn.cursor() 위 표와 같은 데이터베이스 테이블을 생성해 보겠습니다In [2]: # 쿼리를 이용한 테이블 생성 및 값 입력table_create = """ CREATE TABLE name_table( id INTEGER PRIMATY K.. 2024. 9. 14.
ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed- 위 와 같은 에러 메세지가 나타나면 아래 명령어로 nbformat의 버전을 업그레이드해주세요pip install --upgrade nbformat 2024. 8. 25.
ModuleNotFoundError: No module named 'mysql' ModuleNotFoundError: No module named 'mysql'ImportError: 'MySQL'이라는 이름의 모듈이 없습니다.아래 명령어로 mysql 패키지를 설치해주세요 !pip install mysql-connector-python 2024. 8. 23.
HTTPError: HTTP Error 400: Bad Request pytube HTTPError: HTTP Error 400: Bad Request pytube유튜브 다운과정에서 위와 같은 에러가 나오면 아래 코드로 실행해 보세요 # pytubefix 설치#pip install pytubefix# 패키지 불러오기from pytubefix import YouTubefrom pytubefix.cli import on_progress # url 선택url = "url" # 객체 생성yt = YouTube(url, on_progress_callback = on_progress)# 다운로드 실행 ys = yt.streams.get_highest_resolution()ys.download() 2024. 8. 13.