Spaces:
Running
Running
Fixed getLogger, switched level to info from debug
Browse files
app.py
CHANGED
@@ -3,8 +3,8 @@ import logging
|
|
3 |
import time
|
4 |
from transformers import pipeline
|
5 |
|
6 |
-
logger = logging.
|
7 |
-
logger.setLevel(logging.
|
8 |
logging.debug("Starting logging for gradio_test_001.")
|
9 |
|
10 |
classifier = pipeline("zero-shot-classification",
|
@@ -33,12 +33,12 @@ def transform_output(res: dict) -> list:
|
|
33 |
)
|
34 |
|
35 |
def clf_text(txt: str | list[str]):
|
36 |
-
logger.
|
37 |
t0 = time.time()
|
38 |
res = classifier(txt, categories, multi_label=True)
|
39 |
elapsed = time.time() - t0
|
40 |
-
logger.
|
41 |
-
logger.
|
42 |
if isinstance(res, list):
|
43 |
return [ transform_output(dct) for dct in res ]
|
44 |
else:
|
|
|
3 |
import time
|
4 |
from transformers import pipeline
|
5 |
|
6 |
+
logger = logging.getLogger("gradio_test_001")
|
7 |
+
logger.setLevel(logging.INFO)
|
8 |
logging.debug("Starting logging for gradio_test_001.")
|
9 |
|
10 |
classifier = pipeline("zero-shot-classification",
|
|
|
33 |
)
|
34 |
|
35 |
def clf_text(txt: str | list[str]):
|
36 |
+
logger.info("Classify: " + repr(txt))
|
37 |
t0 = time.time()
|
38 |
res = classifier(txt, categories, multi_label=True)
|
39 |
elapsed = time.time() - t0
|
40 |
+
logger.info(f"Done. {elapsed:.02f}s")
|
41 |
+
logger.info(f"Result(s): " + repr(res))
|
42 |
if isinstance(res, list):
|
43 |
return [ transform_output(dct) for dct in res ]
|
44 |
else:
|