darknoon commited on
Commit
8c8fdb8
·
1 Parent(s): d10e0fb
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -11,10 +11,11 @@ import requests
11
  model_path = "facebook/chameleon-7b"
12
  # model = ChameleonForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
13
  # processor = ChameleonProcessor.from_pretrained(model_path)
14
- model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
15
  model.eval()
16
- processor = ChameleonProcessor.from_pretrained(model_path)
17
  tokenizer = processor.tokenizer
 
18
 
19
  @spaces.GPU(duration=90)
20
  def respond(
@@ -38,7 +39,6 @@ def respond(
38
  response = ""
39
 
40
  prompt = "I'm very intrigued by this work of art:<image>Please tell me about the artist."
41
- image = Image.open(requests.get("https://uploads4.wikiart.org/images/paul-klee/death-for-the-idea-1915.jpg!Large.jpg", stream=True).raw)
42
 
43
  inputs = processor(prompt, images=[image], return_tensors="pt").to(model.device, dtype=torch.bfloat16)
44
 
 
11
  model_path = "facebook/chameleon-7b"
12
  # model = ChameleonForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
13
  # processor = ChameleonProcessor.from_pretrained(model_path)
14
+ model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto", use_auth_token=True)
15
  model.eval()
16
+ processor = ChameleonProcessor.from_pretrained(model_path, use_auth_token=True)
17
  tokenizer = processor.tokenizer
18
+ image = Image.open(requests.get("https://uploads4.wikiart.org/images/paul-klee/death-for-the-idea-1915.jpg!Large.jpg", stream=True).raw)
19
 
20
  @spaces.GPU(duration=90)
21
  def respond(
 
39
  response = ""
40
 
41
  prompt = "I'm very intrigued by this work of art:<image>Please tell me about the artist."
 
42
 
43
  inputs = processor(prompt, images=[image], return_tensors="pt").to(model.device, dtype=torch.bfloat16)
44