Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,7 @@ model.generation_config.eos_token_id = processor.tokenizer.eos_token_id
|
|
31 |
@spaces.GPU(duration=120)
|
32 |
def krypton(input, history):
|
33 |
if input["files"]:
|
|
|
34 |
image = input["files"][-1]["path"] if isinstance(input["files"][-1], dict) else input["files"][-1]
|
35 |
else:
|
36 |
image = None
|
@@ -43,10 +44,12 @@ def krypton(input, history):
|
|
43 |
return
|
44 |
|
45 |
prompt = f"user\n\n<image>\n{input['text']}\nassistant\n\n"
|
|
|
46 |
image = Image.open(image)
|
47 |
inputs = processor(prompt, images=image, return_tensors='pt').to(0, torch.float16)
|
48 |
|
49 |
# Streamer
|
|
|
50 |
streamer = TextIteratorStreamer(processor.tokenizer, skip_special_tokens=False, skip_prompt=True)
|
51 |
|
52 |
# Generation kwargs
|
@@ -59,6 +62,7 @@ def krypton(input, history):
|
|
59 |
)
|
60 |
|
61 |
thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
|
|
|
62 |
thread.start()
|
63 |
|
64 |
buffer = ""
|
|
|
31 |
@spaces.GPU(duration=120)
|
32 |
def krypton(input, history):
|
33 |
if input["files"]:
|
34 |
+
print("found the image\n")
|
35 |
image = input["files"][-1]["path"] if isinstance(input["files"][-1], dict) else input["files"][-1]
|
36 |
else:
|
37 |
image = None
|
|
|
44 |
return
|
45 |
|
46 |
prompt = f"user\n\n<image>\n{input['text']}\nassistant\n\n"
|
47 |
+
print("made the prompt")
|
48 |
image = Image.open(image)
|
49 |
inputs = processor(prompt, images=image, return_tensors='pt').to(0, torch.float16)
|
50 |
|
51 |
# Streamer
|
52 |
+
print('About to init streamer')
|
53 |
streamer = TextIteratorStreamer(processor.tokenizer, skip_special_tokens=False, skip_prompt=True)
|
54 |
|
55 |
# Generation kwargs
|
|
|
62 |
)
|
63 |
|
64 |
thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
|
65 |
+
print('threader about to start')
|
66 |
thread.start()
|
67 |
|
68 |
buffer = ""
|