Spaces:
Sleeping
Sleeping
File size: 2,112 Bytes
1609c68 2ee956d ae77df2 2ee956d 1609c68 63f70e6 4e2b617 63f70e6 4e2b617 63f70e6 1609c68 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import streamlit as st
import requests
import io
from PIL import Image, UnidentifiedImageError
import os
import time
st.set_page_config(page_title="Student Assistant")
# API для генерации изображения
API_URL_img = "https://api-inference.huggingface.co/models/playgroundai/playground-v2-1024px-aesthetic"
headers = {"Authorization": os.getenv("api_token")}
# Функция генерации изображения
def generate_img(payload):
response = requests.post(API_URL_img, headers=headers, json=payload)
body = response.json()
while True:
if 'error' in body:
time.sleep(3)
response = requests.post(API_URL_img, headers=headers, json=payload)
body = response.json()
else:
break
return response.content
st.markdown('# :female-student: Персональный помощник для студентов')
st.divider()
st.markdown("# :sparkles: Изучение английского языка через визуальное восприятие")
image_idea = st.text_input('Предложите свою тему для генерации изображения', value="Astronaut riding a horse")
image_gen__btn = st.button('Генерировать изображение')
if image_gen__btn:
with st.spinner('Загрузка изображения...'):
image_bytes = generate_img({"inputs": image_idea})
image_raw = io.BytesIO(image_bytes)
#st.success('Готово')
st.image(image_raw)
st.markdown('## Опишите фотографию на английском языке')
st.markdown('## План ответа поможет вам:')
st.markdown('+ the place;')
st.markdown('+ the action;')
st.markdown('+ the person’s appearance;')
st.markdown('+ whether you like the picture or not;')
st.markdown('+ why.')
st.markdown('Start with: “I’d like to describe this picture. The picture shows …” ')
st.success('Готово')
st.divider() |