wxnono commited on
Commit
838693f
·
verified ·
1 Parent(s): 1905139

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
5
- from transformers import AutoProcessor, AutoModelForVision2Seq
6
 
7
  # 1. Safely extract your secure secret token
8
  hf_token = os.environ.get("HF_TOKEN")
@@ -10,11 +10,11 @@ hf_token = os.environ.get("HF_TOKEN")
10
  # 2. Define target repository path
11
  MODEL_ID = "guangyangmusic/legato-small"
12
 
13
- print("Loading native model architecture and weights...")
14
 
15
- # Pull the processor and custom model definition dynamically from the hub files
16
  processor = AutoProcessor.from_pretrained(MODEL_ID, token=hf_token, trust_remote_code=True)
17
- model = AutoModelForVision2Seq.from_pretrained(
18
  MODEL_ID,
19
  token=hf_token,
20
  trust_remote_code=True,
 
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
5
+ from transformers import AutoProcessor, AutoModelForImageTextToText
6
 
7
  # 1. Safely extract your secure secret token
8
  hf_token = os.environ.get("HF_TOKEN")
 
10
  # 2. Define target repository path
11
  MODEL_ID = "guangyangmusic/legato-small"
12
 
13
+ print("Loading model architecture and weights...")
14
 
15
+ # FIX: Use the updated AutoModelForImageTextToText class for modern transformers compatibility
16
  processor = AutoProcessor.from_pretrained(MODEL_ID, token=hf_token, trust_remote_code=True)
17
+ model = AutoModelForImageTextToText.from_pretrained(
18
  MODEL_ID,
19
  token=hf_token,
20
  trust_remote_code=True,