You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.py 4.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Copyright 2021 The KubeEdge Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from sedna.algorithms.aggregation import MistNet
  15. from sedna.algorithms.client_choose import SimpleClientChoose
  16. from sedna.common.config import Context
  17. from sedna.core.federated_learning import FederatedLearning
  18. simple_chooser = SimpleClientChoose(per_round=1)
  19. # It has been determined that mistnet is required here.
  20. mistnet = MistNet(cut_layer=Context.get_parameters("cut_layer"),
  21. epsilon=Context.get_parameters("epsilon"))
  22. # The function `get_transmitter_from_config()` returns an object instance.
  23. s3_transmitter = FederatedLearning.get_transmitter_from_config()
  24. class Dataset:
  25. def __init__(self) -> None:
  26. self.parameters = {
  27. "datasource": "YOLO",
  28. "data_params": "./coco128.yaml",
  29. # Where the dataset is located
  30. "data_path": "./data/COCO",
  31. "train_path": "./data/COCO/coco128/images/train2017/",
  32. "test_path": "./data/COCO/coco128/images/train2017/",
  33. # number of training examples
  34. "num_train_examples": 128,
  35. # number of testing examples
  36. "num_test_examples": 128,
  37. # number of classes
  38. "num_classes": 80,
  39. # image size
  40. "image_size": 640,
  41. "classes":
  42. [
  43. "person",
  44. "bicycle",
  45. "car",
  46. "motorcycle",
  47. "airplane",
  48. "bus",
  49. "train",
  50. "truck",
  51. "boat",
  52. "traffic light",
  53. "fire hydrant",
  54. "stop sign",
  55. "parking meter",
  56. "bench",
  57. "bird",
  58. "cat",
  59. "dog",
  60. "horse",
  61. "sheep",
  62. "cow",
  63. "elephant",
  64. "bear",
  65. "zebra",
  66. "giraffe",
  67. "backpack",
  68. "umbrella",
  69. "handbag",
  70. "tie",
  71. "suitcase",
  72. "frisbee",
  73. "skis",
  74. "snowboard",
  75. "sports ball",
  76. "kite",
  77. "baseball bat",
  78. "baseball glove",
  79. "skateboard",
  80. "surfboard",
  81. "tennis racket",
  82. "bottle",
  83. "wine glass",
  84. "cup",
  85. "fork",
  86. "knife",
  87. "spoon",
  88. "bowl",
  89. "banana",
  90. "apple",
  91. "sandwich",
  92. "orange",
  93. "broccoli",
  94. "carrot",
  95. "hot dog",
  96. "pizza",
  97. "donut",
  98. "cake",
  99. "chair",
  100. "couch",
  101. "potted plant",
  102. "bed",
  103. "dining table",
  104. "toilet",
  105. "tv",
  106. "laptop",
  107. "mouse",
  108. "remote",
  109. "keyboard",
  110. "cell phone",
  111. "microwave",
  112. "oven",
  113. "toaster",
  114. "sink",
  115. "refrigerator",
  116. "book",
  117. "clock",
  118. "vase",
  119. "scissors",
  120. "teddy bear",
  121. "hair drier",
  122. "toothbrush",
  123. ],
  124. "partition_size": 128,
  125. }
  126. class Estimator:
  127. def __init__(self) -> None:
  128. self.model = None
  129. self.hyperparameters = {
  130. "type": "yolov5",
  131. "rounds": 1,
  132. "target_accuracy": 0.99,
  133. "epochs": 500,
  134. "batch_size": 16,
  135. "optimizer": "SGD",
  136. "linear_lr": False,
  137. # The machine learning model
  138. "model_name": "yolov5",
  139. "model_config": "./yolov5s.yaml",
  140. "train_params": "./hyp.scratch.yaml"
  141. }