https://docs.streamlit.io/library/api-reference
Streamlit Docs
Join the community Streamlit is more than just a way to make data apps, it's also a community of creators that share their apps and ideas and help each other make their work better. Please come join us on the community forum. We love to hear your questions
docs.streamlit.io
pip install streamlit openai
WARNING: Failed to write executable - trying to use .deleteme logic
ERROR: Could not install packages due to an OSError: [WinError 2] 지정된 파일을 찾을 수 없습니다:
'C:\\Python311\\Scripts\\watchmedo.exe' ->
'C:\\Python311\\Scripts\\watchmedo.exe.deleteme'
>>> 가상환경 재진입
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-intel 2.12.0 requires numpy<1.24,>=1.22, but you have numpy 1.24.3 which is incompatible.
>>> tensorflow-intel 패키지가 numpy 버전 1.24보다 작고 1.22 이상을 요구하지만,
현재 설치된 numpy 버전은 1.24.3이라서 호환되지 않는다는 것
>>> pip install --upgrade tensorflow-intel
tensorflow-intel 패키지 업그레이드
>>> pip install numpy==1.23
numpy 패키지를 특정 버전으로 다운그레이드
import streamlit as st
st.title("ChatGPT Plus DALL-E")
with st.form("form"):
user_input = st.text_input("Prompt")
submit = st.form_submit_button("Submit")
if submit:
st.write(user_input)
streamlit run app.py
> Email 입력
openai
import streamlit as st
import openai
openai.api_key = "" # key
st.title("ChatGPT Plus DALL-E")
with st.form("form"):
user_input = st.text_input("Prompt")
submit = st.form_submit_button("Submit")
if submit:
st.write(user_input)
gpt_prompt = []
# 시스템 메세지
gpt_prompt.append({
"role": "system",
"content": "Imagine the detail appearance of the input. Response shortly."
})
# 사용자의 입력
gpt_prompt.append({
"role": "user",
"content": user_input
})
prompt = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=gpt_prompt)
st.markdown(prompt)
json 형태의 output이 나오는데 "content" 부분만 가져오기
st.markdown(prompt["choices"][0]["message"]["content"])
prompt = st.markdown(prompt["choices"][0]["message"]["content"])
st.caption(prompt)
DALL-E
import streamlit as st
import openai
openai.api_key = "" # key
st.title("ChatGPT Plus DALL-E")
with st.form("form"):
user_input = st.text_input("Prompt")
submit = st.form_submit_button("Submit")
if submit:
st.write(user_input)
# ChatGPT
gpt_prompt = []
# 시스템 메세지
gpt_prompt.append({
"role": "system",
"content": "Imagine the detail appearance of the input. Response shortly."
})
# 사용자의 입력
gpt_prompt.append({
"role": "user",
"content": user_input
})
prompt = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=gpt_prompt)
prompt = prompt["choices"][0]["message"]["content"]
st.caption(prompt)
# DALL-E
result = openai.Image.create(
prompt=prompt,
size="1024x1024"
)
st.image(result["data"][0]["url"])
????????????? 영어로 입력하기
with st.spinner("Wating for ChatGPT..."):
prompt = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=gpt_prompt)
# DALL-E
with st.spinner("Wating for DALL-E..."):
result = openai.Image.create(
prompt=prompt,
size="1024x1024"
)
완성 코드
import streamlit as st
import openai
openai.api_key = "" # key
st.title("ChatGPT Plus DALL-E")
with st.form("form"):
user_input = st.text_input("Prompt")
submit = st.form_submit_button("Submit")
if submit:
st.write(user_input)
# ChatGPT
gpt_prompt = []
# 시스템 메세지
gpt_prompt.append({
"role": "system",
"content": "Imagine the detail appearance of the input. Response shortly."
})
# 사용자의 입력
gpt_prompt.append({
"role": "user",
"content": user_input
})
with st.spinner("Wating for ChatGPT..."):
prompt = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=gpt_prompt)
prompt = prompt["choices"][0]["message"]["content"]
st.caption(prompt)
# DALL-E
with st.spinner("Wating for DALL-E..."):
result = openai.Image.create(
prompt=prompt,
size="1024x1024"
)
st.image(result["data"][0]["url"])
'딥러닝' 카테고리의 다른 글
딥러닝 5주차_흑백사진을 컬러사진으로, 해상도 향상 인공지능 (5) | 2023.05.18 |
---|---|
딥러닝 4주차_얼굴인식 인공지능 스노우 앱 (3) | 2023.05.18 |
딥러닝 3주차_마스크 착용 여부, 성별 나이 예측 (2) | 2023.05.18 |
딥러닝 2주차_유명 화가의 화풍을 따라하는 인공지능 (2) | 2023.05.18 |
딥러닝 1주차_이미지 동영상 처리 (1) | 2023.05.18 |