Spaces:
Running
on
Zero
Running
on
Zero
Update multipurpose_chatbot/engines/sealmmm_engine.py
Browse files
multipurpose_chatbot/engines/sealmmm_engine.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
# from transformers_stream_generator import init_stream_support
|
2 |
# init_stream_support()
|
3 |
|
|
|
4 |
import os
|
5 |
import numpy as np
|
6 |
import argparse
|
7 |
-
import spaces
|
8 |
import torch
|
9 |
import gradio as gr
|
10 |
from typing import Any, Iterator
|
@@ -212,6 +212,11 @@ class SeaLMMMv0Engine(TransformersEngine):
|
|
212 |
|
213 |
images = [Image.open(x) for x in image_paths] if len(image_paths) > 0 else None
|
214 |
|
|
|
|
|
|
|
|
|
|
|
215 |
with torch.no_grad():
|
216 |
inputs = self.processor(prompt, images, return_tensors='pt')
|
217 |
# inputs = {k: v.to("cuda", torch.bfloat16) for k, v in inputs.items() if v is not None}
|
|
|
1 |
# from transformers_stream_generator import init_stream_support
|
2 |
# init_stream_support()
|
3 |
|
4 |
+
import spaces
|
5 |
import os
|
6 |
import numpy as np
|
7 |
import argparse
|
|
|
8 |
import torch
|
9 |
import gradio as gr
|
10 |
from typing import Any, Iterator
|
|
|
212 |
|
213 |
images = [Image.open(x) for x in image_paths] if len(image_paths) > 0 else None
|
214 |
|
215 |
+
# 4.38 .sample
|
216 |
+
# 4.39 ._sample
|
217 |
+
# need to put @spaces.GPU on the gradio function call
|
218 |
+
self._model.sample = types.MethodType(NewGenerationMixin.sample_stream, self._model)
|
219 |
+
|
220 |
with torch.no_grad():
|
221 |
inputs = self.processor(prompt, images, return_tensors='pt')
|
222 |
# inputs = {k: v.to("cuda", torch.bfloat16) for k, v in inputs.items() if v is not None}
|