Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,8 @@ def model_inference(
|
|
21 |
input_dict, history, decoding_strategy, temperature, max_new_tokens,
|
22 |
repetition_penalty, top_p
|
23 |
):
|
|
|
|
|
24 |
text = input_dict["text"]
|
25 |
print(input_dict["files"])
|
26 |
if len(input_dict["files"]) > 1:
|
@@ -72,6 +74,7 @@ def model_inference(
|
|
72 |
generation_args = dict(inputs, streamer=streamer, max_new_tokens=max_new_tokens)
|
73 |
generated_text = ""
|
74 |
|
|
|
75 |
thread = Thread(target=model.generate, kwargs=generation_args)
|
76 |
thread.start()
|
77 |
thread.join()
|
@@ -81,11 +84,13 @@ def model_inference(
|
|
81 |
|
82 |
for new_text in streamer:
|
83 |
|
|
|
84 |
buffer += new_text
|
85 |
generated_text_without_prompt = buffer#[len(ext_buffer):]
|
86 |
time.sleep(0.01)
|
87 |
yield buffer
|
88 |
|
|
|
89 |
|
90 |
examples=[
|
91 |
[{"text": "What art era do these artpieces belong to?", "files": ["example_images/rococo.jpg", "example_images/rococo_1.jpg"]}, "Greedy", 0.4, 512, 1.2, 0.8],
|
|
|
21 |
input_dict, history, decoding_strategy, temperature, max_new_tokens,
|
22 |
repetition_penalty, top_p
|
23 |
):
|
24 |
+
print("Processing")
|
25 |
+
t0 = time.perf_counter()
|
26 |
text = input_dict["text"]
|
27 |
print(input_dict["files"])
|
28 |
if len(input_dict["files"]) > 1:
|
|
|
74 |
generation_args = dict(inputs, streamer=streamer, max_new_tokens=max_new_tokens)
|
75 |
generated_text = ""
|
76 |
|
77 |
+
print("model.generate")
|
78 |
thread = Thread(target=model.generate, kwargs=generation_args)
|
79 |
thread.start()
|
80 |
thread.join()
|
|
|
84 |
|
85 |
for new_text in streamer:
|
86 |
|
87 |
+
print("First stream chunk")
|
88 |
buffer += new_text
|
89 |
generated_text_without_prompt = buffer#[len(ext_buffer):]
|
90 |
time.sleep(0.01)
|
91 |
yield buffer
|
92 |
|
93 |
+
print("total time", time.perf_counter() - t0)
|
94 |
|
95 |
examples=[
|
96 |
[{"text": "What art era do these artpieces belong to?", "files": ["example_images/rococo.jpg", "example_images/rococo_1.jpg"]}, "Greedy", 0.4, 512, 1.2, 0.8],
|