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)에서 원소 추가/제거

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


파이썬에서 key:value 형태로 구성된 딕셔너리(dict)에서 특정 키(key)에 대응하는 원소를 추가/제거하는 방법입니다.

원소 추가는 간단합니다. 변수를 딕셔너리 형식으로 초기화한 후에 원소를 할당해 주면 됩니다.

# x_dict 변수 초기화(딕셔너리 형식)
x_dict = {}
# 원소 추가 - 키 'abc', 값 100
x_dict['abc'] = 100
# 2개 더 추가
x_dict['def'] = 50
x_dict['xyz'] = 99

당연히 아래와 같이 변수 x_dict의 내용을 한번에 할당해도 됩니다.

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

이제 제거해 보겠습니다. x_dict에서 키 'def'에 대응하는 원소를 제거하려면 pop()을 사용합니다. 아래와 같습니다.

x_dict.pop('def')

이제 x_dict의 내용을 확인해 보면 해당 원소가 사라진 것으로 볼 수 있습니다.

print(x_dict)

{'abc': 100, 'xyz': 99}

제거하면서 해당 원소를 다른 변수에 할당할 수 있습니다. 이번에는 키 'xyz'에 대응하는 원소를 제거하면서 이 값을 변수 y에 할당해 봅니다.

y = x_dict.pop('xyz')

키 'xyz'에 대응하는 값은 99였으므로, 변수 y에 99가 할당되고 x_dict에서는 이 원소가 제거되었습니다.

print(y)

99

print(x_dict)

{'abc': 100}

Comments

Popular posts from this blog

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

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

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