Um modo de executar no Colab Google
#1
by
EduardoBbastos
- opened
I am building and sharing a way to consume the model in Google Colab.
import huggingface_hub
import requests
import io
from PIL import Image
import datetime
API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Canopus-Interior-Architecture-0.1"
headers = {"Authorization": "Bearer hf_XXXXXXXXXXXXX"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
while True:
prompt = input("Digite sua descrição (ou 'sair' para encerrar): ")
if prompt.lower() == 'sair':
break
image_bytes = query({
"inputs": prompt,
})
image = Image.open(io.BytesIO(image_bytes))
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
image.save(f'/content/sample_data/generated_image_{timestamp}.png')
print(f"Imagem salva em /content/sample_data/generated_image_{timestamp}.png")