lihao57 commited on
Commit
cc5da1d
·
1 Parent(s): e602299

support local dataset

Browse files
Files changed (2) hide show
  1. README.md +17 -0
  2. app.py +9 -3
README.md CHANGED
@@ -12,3 +12,20 @@ short_description: Wireframe Dataset (for Line Segment Detection) Space
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
15
+
16
+ # Install
17
+ ```shell
18
+ git clone https://huggingface.co/spaces/lh9171338/Wireframe
19
+ cd Wireframe
20
+ python3 -m pip install -r requirements.txt
21
+ ```
22
+
23
+ # Run
24
+
25
+ ```shell
26
+ # using Huggingface online dataset
27
+ python3 app.py -d lh9171338/Wireframe -s all
28
+
29
+ # using local dataset
30
+ python3 app.py -d <DATASET_PATH> -l True -s all
31
+ ```
app.py CHANGED
@@ -18,7 +18,8 @@ from datasets import load_dataset
18
 
19
  ds = None
20
  DATASET_NAME = None
21
- FAST = True
 
22
  SPLIT = "all"
23
 
24
 
@@ -34,7 +35,10 @@ def get_dataset():
34
  """
35
  global ds
36
  if ds is None:
37
- ds = load_dataset(DATASET_NAME)
 
 
 
38
  return ds
39
 
40
 
@@ -146,11 +150,13 @@ def main():
146
  if __name__ == "__main__":
147
  argparser = argparse.ArgumentParser()
148
  argparser.add_argument("-n", "--dataset_name", type=str, help="dataset name", default="lh9171338/Wireframe")
149
- argparser.add_argument("-f", "--fast", type=bool, help="whether to use fast drawing method", default=True)
 
150
  argparser.add_argument("-s", "--split", type=str, help="split", default="all", choices=["all", "train", "test"])
151
  args = argparser.parse_args()
152
  print(args)
153
  DATASET_NAME = args.dataset_name
 
154
  FAST = args.fast
155
  SPLIT = args.split
156
  main()
 
18
 
19
  ds = None
20
  DATASET_NAME = None
21
+ LOCAL = False
22
+ FAST = False
23
  SPLIT = "all"
24
 
25
 
 
35
  """
36
  global ds
37
  if ds is None:
38
+ if LOCAL:
39
+ ds = load_dataset("imagefolder", data_dir=DATASET_NAME)
40
+ else:
41
+ ds = load_dataset(DATASET_NAME)
42
  return ds
43
 
44
 
 
150
  if __name__ == "__main__":
151
  argparser = argparse.ArgumentParser()
152
  argparser.add_argument("-n", "--dataset_name", type=str, help="dataset name", default="lh9171338/Wireframe")
153
+ argparser.add_argument("-l", "--local", type=bool, help="use local data or not", default=False)
154
+ argparser.add_argument("-f", "--fast", type=bool, help="whether to use fast drawing method", default=False)
155
  argparser.add_argument("-s", "--split", type=str, help="split", default="all", choices=["all", "train", "test"])
156
  args = argparser.parse_args()
157
  print(args)
158
  DATASET_NAME = args.dataset_name
159
+ LOCAL = args.local
160
  FAST = args.fast
161
  SPLIT = args.split
162
  main()