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...

파이썬의 딕셔너리(dict)에서 특정 키(key)가 존재하는지 확인하기

by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/dict-key


key:value 형태로 구성되는 딕셔너리(dict) 형식의 변수에서 특정한 키(key)가 포함되어 있는지 확인하는 방법입니다.

일단 아래와 같이 x_dict라는 변수를 생각해 봅니다.

x_dict = { 'abc':100, 'def':50, 'xyz':99 }

x_dict에 "def"라는 키가 있는지 확인하려면 간단하게 if 조건문으로 가능합니다.

if 'def' in x_dict:
  print('x_dict에 키 def가 존재합니다.')
else:
  print('x_dict에 키 def가 존재하지 않습니다.')

딕셔너리의 value 항목을 리스트(list) 또는 딕셔너리로 구성하려면 실제 값을 할당하기 전에 초기화를 해 주어야 하는데, 이와 관련하여 간단한 예시를 메모해 둡니다.

target_list = { 'abc':[1,2,3] }
target_key = 'def'

if target_key in target_list:
  # value에 10을 추가, 리스트 형태이므로 append() 사용
  target_list[target_key].append(10)
else:
  print("target_list에 ", target_key, "키가 없습니다."
  # value를 리스트 형식으로 선언한 후에 value에 10을 추가
  target_list[target_key] = []
  target_list[target_key].append(10)

print(target_list)

{'abc': [1, 2, 3], 'def': [10]}

Comments

Popular posts from this blog

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

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

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