Как загрузить модель объятия лица локально для использования с langchain, хостом и потоком?Python

Программы на Python
Anonymous
Как загрузить модель объятия лица локально для использования с langchain, хостом и потоком?

Сообщение Anonymous »

Я пытаюсь создать приложение искусственного интеллекта с помощью langchain и Huggingface. Я получил следующую ошибку:

{ "ошибка": "Не удалось загрузить модель paragon-AI/blip2-image-to-text с любым из следующего классы: (,). См. исходные ошибки:\n\nпри загрузке с помощью Blip2ForConditionalGeneration выдается ошибка:\nTraceback (последний вызов):\n Файл "/src/transformers/src/transformers/pipelines/base.py", строка 269, в infer_framework_load_model\n model = model_class.from_pretrained(model, **kwargs)\n Файл "/src/transformers/src/transformers/modeling_utils .py", строка 3138, в from_pretrained\n поднять EnvironmentError(\nOSError: у paragon-AI/blip2-image-to-text нет файла с именем pytorch_model.bin, tf_model.h5, model.ckpt или flax_model. msgpack.\n\n\n"
}

import streamlit as st
import requests
from PIL import Image
from io import BytesIO
from transformers import AutoModelForCausalLM

def main():
st.title("Image to Text and Audio Converter")

# Upload image file
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
# Display uploaded image
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)

# Convert image to text
st.subheader("Image to Text")
text_output = convert_image_to_text(uploaded_file)
st.write(text_output)

# Convert image to audio
st.subheader("Image to Audio")
audio_output = convert_image_to_audio(uploaded_file)
st.audio(audio_output)

def convert_image_to_text(image_file):
IMAGE_TO_TEXT_API_URL = "https://api-inference.huggingface.co/mo ... ge-to-text"
IMAGE_TO_TEXT_HEADERS = {"Authorization": "Bearer apikey"}

response = requests.post(IMAGE_TO_TEXT_API_URL, headers=IMAGE_TO_TEXT_HEADERS, files={"file": image_file})
return response.json()

def convert_image_to_audio(image_file):
IMAGE_TO_AUDIO_API_URL = "https://api-inference.huggingface.co/mo ... ning-large"
IMAGE_TO_AUDIO_HEADERS = {"Authorization": "Bearer apikey"}

response = requests.post(IMAGE_TO_AUDIO_API_URL, headers=IMAGE_TO_AUDIO_HEADERS, files={"file": image_file})
return response.content

if __name__ == "__main__":
main()


Подробнее здесь: https://stackoverflow.com/questions/775 ... -and-strea

Вернуться в «Python»