|
5 | 5 | import argparse |
6 | 6 | import ast |
7 | 7 | import os |
8 | | -import pickle |
9 | 8 | import threading |
10 | 9 |
|
11 | 10 | from flask import Blueprint, Flask, Response, request |
@@ -91,14 +90,20 @@ def get(self): |
91 | 90 | # print("Caught Exception: ", e) |
92 | 91 | # return Response(e) |
93 | 92 |
|
94 | | - feature = pickle.loads(request.get_data()) |
95 | | - feature["api"] = "vae" |
96 | | - |
97 | | - feature = {k: v for k, v in feature.items() if v is not None} |
98 | | - video_latents = self.vae_pipeline.decode(**feature) |
99 | | - |
100 | | - response = pickle.dumps(video_latents) |
101 | | - |
| 93 | + print( |
| 94 | + "Using pickle to transfer data may bring security risks. " |
| 95 | + "Please confirm the security risks before using this API." |
| 96 | + "You can remove the comment markers of L99 ~ L104 and " |
| 97 | + "add a comment marker at L105 ~ L106 to re-enable the code." |
| 98 | + ) |
| 99 | + # import pickle |
| 100 | + # feature = pickle.loads(request.get_data()) |
| 101 | + # feature["api"] = "vae" |
| 102 | + # feature = {k: v for k, v in feature.items() if v is not None} |
| 103 | + # video_latents = self.vae_pipeline.decode(**feature) |
| 104 | + # response = pickle.dumps(video_latents) |
| 105 | + feature = request.get_data() |
| 106 | + response = feature |
102 | 107 | return Response(response) |
103 | 108 |
|
104 | 109 |
|
@@ -164,13 +169,20 @@ def get(self): |
164 | 169 | # print("Caught Exception: ", e) |
165 | 170 | # return Response(e) |
166 | 171 |
|
167 | | - feature = pickle.loads(request.get_data()) |
168 | | - feature["api"] = "caption" |
169 | | - |
170 | | - feature = {k: v for k, v in feature.items() if v is not None} |
171 | | - embeddings = self.caption_pipeline.embedding(**feature) |
172 | | - response = pickle.dumps(embeddings) |
173 | | - |
| 172 | + print( |
| 173 | + "Using pickle to transfer data may bring security risks. " |
| 174 | + "Please confirm the security risks before using this API." |
| 175 | + "You can remove the comment markers of L178 ~ L183 and " |
| 176 | + "add a comment marker at L184 ~ L185 to re-enable the code." |
| 177 | + ) |
| 178 | + # import pickle |
| 179 | + # feature = pickle.loads(request.get_data()) |
| 180 | + # feature["api"] = "caption" |
| 181 | + # feature = {k: v for k, v in feature.items() if v is not None} |
| 182 | + # embeddings = self.caption_pipeline.embedding(**feature) |
| 183 | + # response = pickle.dumps(embeddings) |
| 184 | + feature = request.get_data() |
| 185 | + response = feature |
174 | 186 | return Response(response) |
175 | 187 |
|
176 | 188 |
|
|
0 commit comments