makakwastaken commited on
Commit
882d74d
·
1 Parent(s): 7857874

Removed outdated code in app.py

Browse files
Files changed (2) hide show
  1. app.py +3 -55
  2. start.py +0 -5
app.py CHANGED
@@ -1,57 +1,5 @@
1
- #!/usr/bin/env python
2
 
3
- import pathlib
4
 
5
- import gradio as gr
6
- import numpy as np
7
- import PIL.Image as Image
8
-
9
- from model import Model
10
- import base64
11
- from io import BytesIO
12
-
13
- model = Model()
14
-
15
-
16
- def run(image_path, threshold, num_objects):
17
- image = Image.open(image_path).convert('RGB')
18
- canvas = Image.new('RGB', image.size, (0, 0, 0))
19
-
20
- # We copy the image that and fill it with black, to get the dimensions
21
- rgb = np.array(canvas)
22
- masks = model(image_path, threshold, num_objects)
23
-
24
- for mask in masks:
25
- fg = mask > 0.5
26
- rgb[fg] = 255
27
-
28
- return Image.fromarray(rgb)
29
-
30
-
31
- TITLE = 'MaskCut'
32
- DESCRIPTION = 'This is an unofficial demo for https://github.com/facebookresearch/CutLER.'
33
-
34
- paths = sorted(pathlib.Path('CutLER/maskcut/imgs').glob('*.jpg'))
35
- demo = gr.Interface(fn=run,
36
- enable_queue=True,
37
- inputs=[
38
- gr.Image(label='Input image', type='filepath'),
39
- gr.Slider(
40
- label='Threshold used for producing binary graph',
41
- minimum=0,
42
- maximum=1,
43
- value=0.15,
44
- step=0.01),
45
- gr.Slider(
46
- label='Number of objects in the image',
47
- minimum=1,
48
- maximum=10,
49
- value=1,
50
- step=1)
51
- ],
52
- outputs=gr.Image(label='Output image', type="pil"),
53
- examples=[[path.as_posix(), 0.15, 2] for path in paths],
54
- title=TITLE,
55
- description=DESCRIPTION)
56
- demo.queue(concurrency_count=3, api_open=True)
57
- demo.launch()
 
1
+ import subprocess
2
 
3
+ # Start HF-MaskCut with uvicorn
4
 
5
+ subprocess.run(["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
start.py DELETED
@@ -1,5 +0,0 @@
1
- import subprocess
2
-
3
- # Start HF-MaskCut with uvicorn
4
-
5
- subprocess.run(["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"])