Spaces:
Runtime error
Runtime error
Thiago Hersan
commited on
Commit
•
c15e860
1
Parent(s):
9b6c847
rm examples and debug prints
Browse files- app.py +1 -44
- examples/map-000.jpg +0 -0
- examples/map-114.jpg +0 -0
- requirements.txt +0 -1
app.py
CHANGED
@@ -2,8 +2,6 @@ import glob
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
-
import psutil
|
6 |
-
from threading import Timer
|
7 |
from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor
|
8 |
|
9 |
|
@@ -75,15 +73,6 @@ def query_image(image_path):
|
|
75 |
return mask_img, dataframe
|
76 |
|
77 |
|
78 |
-
def get_system_memory():
|
79 |
-
memory = psutil.virtual_memory()
|
80 |
-
memory_percent = memory.percent
|
81 |
-
memory_used = memory.used / (1024.0 ** 3)
|
82 |
-
memory_total = memory.total / (1024.0 ** 3)
|
83 |
-
print({"used": f"{memory_used:.3f}GB", "total": f"{memory_total:.3f}GB", "percent": f"{memory_percent}%"})
|
84 |
-
return ""
|
85 |
-
|
86 |
-
|
87 |
demo = gr.Interface(
|
88 |
title="Maskformer (large-coco)",
|
89 |
description="Using [facebook/maskformer-swin-large-coco](https://huggingface.co/facebook/maskformer-swin-large-coco) model to calculate percentage of pixels in an image that belong to vegetation.",
|
@@ -102,36 +91,4 @@ demo = gr.Interface(
|
|
102 |
analytics_enabled=None
|
103 |
)
|
104 |
|
105 |
-
|
106 |
-
class RepeatedTimer(object):
|
107 |
-
def __init__(self, interval, function, *args, **kwargs):
|
108 |
-
self._timer = None
|
109 |
-
self.interval = interval
|
110 |
-
self.function = function
|
111 |
-
self.args = args
|
112 |
-
self.kwargs = kwargs
|
113 |
-
self.is_running = False
|
114 |
-
self.start()
|
115 |
-
|
116 |
-
def _run(self):
|
117 |
-
self.is_running = False
|
118 |
-
self.start()
|
119 |
-
self.function(*self.args, **self.kwargs)
|
120 |
-
|
121 |
-
def start(self):
|
122 |
-
if not self.is_running:
|
123 |
-
self._timer = Timer(self.interval, self._run)
|
124 |
-
self._timer.start()
|
125 |
-
self.is_running = True
|
126 |
-
|
127 |
-
def stop(self):
|
128 |
-
self._timer.cancel()
|
129 |
-
self.is_running = False
|
130 |
-
|
131 |
-
rt = RepeatedTimer(1, get_system_memory)
|
132 |
-
|
133 |
-
try:
|
134 |
-
print("launch")
|
135 |
-
demo.queue().launch(show_api=False, debug=True)
|
136 |
-
finally:
|
137 |
-
rt.stop()
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
|
|
|
|
5 |
from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor
|
6 |
|
7 |
|
|
|
73 |
return mask_img, dataframe
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
demo = gr.Interface(
|
77 |
title="Maskformer (large-coco)",
|
78 |
description="Using [facebook/maskformer-swin-large-coco](https://huggingface.co/facebook/maskformer-swin-large-coco) model to calculate percentage of pixels in an image that belong to vegetation.",
|
|
|
91 |
analytics_enabled=None
|
92 |
)
|
93 |
|
94 |
+
demo.launch(show_api=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/map-000.jpg
DELETED
Binary file (258 kB)
|
|
examples/map-114.jpg
DELETED
Binary file (152 kB)
|
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
Pillow
|
2 |
-
psutil
|
3 |
scipy
|
4 |
torch
|
5 |
transformers
|
|
|
1 |
Pillow
|
|
|
2 |
scipy
|
3 |
torch
|
4 |
transformers
|