jsup.GEN - working on image-to-image generation with AI

Image
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-gen-working-on-image-to-image-generation-with-ai Hello, this is @joviansummer(witness: @jswit). I'd like to share what I'm working on regarding my experintal jsup.GEN project, which tries to connect image generation AI with Steemit. Currently, jsup.GEN provide function to generate image from test prompt(txt2img). This function is interesting, but it's not easy to generate exactly what you want because you need to explain the image in detail with multiple keywords in English. Thus, I think it's more useful to have a function to generate image from existing reference image. I'm working on this image-to-image function, and thinking about two methods to implement it. The first method is to provide 2 commands as follows: !gen_t : This command focuses more on text prompt than reference image. The result may be quite different from reference because text prompt will have much more in...

파이썬에서 시간대(timezone) 변경

by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/timezone


파이썬에서 시간대(timezone)를 변경하는 방법을 간단하게 메모해 둡니다.

datetime 모듈과 dateutil 모듈을 사용해서 현재 시간을 다른 시간대로 변환해서 출력할 수 있습니다.

from datetime import datetime
import pytz

# 현재 시각을 UTC/GMT 기준으로 now에 할당
now = datetime.utcnow()

# 현재 시각을 지역 시간대 기준으로 now_local에 할당
now_local = datetime.now()

datetime 객체인 now에 저장된 시간 정보를 원하는 형식에 맞춰서 문자열로 출력하기 위해 strftime() 함수를 이용합니다.

# 현재 시각 출력 (UTC/GMT)
now.strftime("%Y-%m-%d %H:%M:%S")

'2021-04-10 13:48:54'

# 현재 시각 출력 (KST)
now_local.strftime("%Y-%m-%d %H:%M:%S")

'2021-04-10 22:48:54'

위의 값은 UTC/GMT 기준이므로, 이것을 한국 시간대로 바꿉니다. 우선 시간대 정보(tzinfo)를 가져와 변수 UTC, KST에 할당합니다.

# 한국 시간대 정보를 KST에 할당
UTC = pytz.timezone('UTC')
KST = pytz.timezone('Asia/Seoul')

now에 할당된 datetime 객체에 시간대가 GMT/UTC라는 정보를 추가합니다.

# now의 시간대 정보를 UTC로 설정하여 now_utc에 할당
now_utc = now.replace(tzinfo=UTC)

now_utc의 시간대가 GMT/UTC라고 명시되었으므로, 이 시간 정보를 다른 시간대 기준으로 환산할 수 있습니다.

# now_utc의 시간대를 한국 시간대로 변환하여 now_kst에 할당
now_kst=now_utc.astimezone(KST)

시간대 정보를 한국 시간대로 변경한 now_kst의 시간 정보를 출력해 봅니다.

now_kst.strftime("%Y-%m-%d %H:%M:%S") '2021-04-10 22:48:54'

Comments

Popular posts from this blog

스티미언의 영향력 지수 계산

jsup/avle 보팅 코드 갱신 - 1일1포스팅 강박에서 벗어나기

jsup/avle code update - you don't have to write post everyday