index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
47,263
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_conditional_formatting.py
23,24
1,112
conditional_formatting
30,108
24,108
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) my_range = { "sheetId": 0, "startRowIndex": 1, "endRowIndex": 11, "startColumnIndex": 0, "endColumnIndex": 4, } requests = [ {...
""" Creates the batch_update the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
135
352
641
993
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,264
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_create.py
23,24
1,51
create
30,47
24,47
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) spreadsheet = {"properties": {"title": title}} spreadsheet = ( service.spreadsheets() .create(body=spreadsheet, fields="spreadsheetId") .execute() ) ...
""" Creates the Sheet the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: s...
41
300
188
488
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,265
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_filter_views.py
23,24
1,120
filter_views
30,116
24,116
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) my_range = { "sheetId": 0, "startRowIndex": 0, "startColumnIndex": 0, } addfilterviewrequest = { "addFilterView": { "filter": { ...
""" Creates the batch_update the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
155
346
765
1,111
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,266
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_get_values.py
23,24
1,53
get_values
30,49
24,49
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) result = ( service.spreadsheets() .values() .get(spreadsheetId=spreadsheet_id, range=range_name) .execute() ) rows = result.get("values", []) ...
""" Creates the batch_update the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
41
362
177
539
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,267
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_pivot_tables.py
23,24
1,115
pivot_tables
30,111
24,111
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) # Create two sheets for our pivot table. body = {"requests": [{"addSheet": {}}, {"addSheet": {}}]} batch_update_response = ( service.spreadsheets() .batchUpdat...
""" Creates the batch_update the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
150
350
715
1,065
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,268
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/sheets_update_values.py
23,24
1,71
update_values
30,62
24,62
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("sheets", "v4", credentials=creds) values = [ [ # Cell values ... ], # Additional rows ... ] # [START_EXCLUDE silent] values = _values # [END_EXCLUDE] body = {"va...
""" Creates the batch_update the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
67
414
269
683
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,269
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_append_values.py
23,24
20,39
test_append_values
Testappendvalues
25,39
24,39
class Testappendvalues(BaseTest): """Unit test for append value Sheet snippet""" def test_append_values(self): FILL_FUNC_BODY
class Testappendvalues(BaseTest): """Unit test for append value Sheet snippet""" def test_append_values(self): """test append values function""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_append_values.append_values( spreadsheet_id, "Sheet1", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual("Sheet1!A1:J10", result.get("tableRange")) ...
"""test append values function""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_append_values.append_values( spreadsheet_id, "Sheet1", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual("Shee...
29
53
214
267
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,270
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_batch_get_values.py
23,24
20,38
test_batch_get_values
Testgetvalues
25,38
24,38
class Testgetvalues(BaseTest): """Unit test class for get value Sheet snippet""" def test_batch_get_values(self): FILL_FUNC_BODY
class Testgetvalues(BaseTest): """Unit test class for get value Sheet snippet""" def test_batch_get_values(self): """test batch get values function""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_batch_get_values.batch_get_values( spreadsheet_id, ["A1:A3", "B1:C1"] ) self.assertIsNotNone(result) valueranges = result.get("valueRanges") self.assertIsNotNone(valueranges) self...
"""test batch get values function""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_batch_get_values.batch_get_values( spreadsheet_id, ["A1:A3", "B1:C1"] ) self.assertIsNotNone(result) valueranges = result.get("valueRanges") s...
23
57
167
224
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,271
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_batch_update.py
24,25
21,40
test_batch_update
Testbatchupdate
26,40
25,40
class Testbatchupdate(BaseTest): """Unit test class for Batch update Sheet snippet""" def test_batch_update(self): FILL_FUNC_BODY
class Testbatchupdate(BaseTest): """Unit test class for Batch update Sheet snippet""" def test_batch_update(self): """test_batch_update function""" FILL_FUNC_BODY
spreadsheet_id = sheets_create.create("Title") self.populate_values(spreadsheet_id) response = sheets_batch_update.sheets_batch_update( spreadsheet_id, "New Title", "Hello", "Goodbye" ) self.assertIsNotNone(response) replies = response.get("replies") self.assertIsNotNone(replies) ...
"""test_batch_update function""" spreadsheet_id = sheets_create.create("Title") self.populate_values(spreadsheet_id) response = sheets_batch_update.sheets_batch_update( spreadsheet_id, "New Title", "Hello", "Goodbye" ) self.assertIsNotNone(response) replies = response.get("replies") ...
26
57
189
246
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,272
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_batch_update_values.py
23,24
20,36
test_batch_update_values
Testbatchupdatevalues
25,36
24,36
class Testbatchupdatevalues(BaseTest): """Unit test for Batch update value Sheet snippet""" def test_batch_update_values(self): FILL_FUNC_BODY
class Testbatchupdatevalues(BaseTest): """Unit test for Batch update value Sheet snippet""" def test_batch_update_values(self): """batch updates values""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() result = sheets_batch_update_values.batch_update_values( spreadsheet_id, "A1:B2", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual(1, len(result.get("responses"))) self.assertEqual(2, result.get("tota...
"""batch updates values""" spreadsheet_id = self.create_test_spreadsheet() result = sheets_batch_update_values.batch_update_values( spreadsheet_id, "A1:B2", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual(1, len(result.get("responses"))) self....
23
57
164
221
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,273
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_conditional_formatting.py
23,24
20,33
test_conditional_formatting
Testconditionalformatting
25,33
24,33
class Testconditionalformatting(BaseTest): """Unit test for sheets conditional_formatting value Sheet snippet""" def test_conditional_formatting(self): FILL_FUNC_BODY
class Testconditionalformatting(BaseTest): """Unit test for sheets conditional_formatting value Sheet snippet""" def test_conditional_formatting(self): """sheets_conditional_formatting function""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) response = sheets_conditional_formatting.conditional_formatting( spreadsheet_id ) self.assertEqual(2, len(response.get("replies")))
"""sheets_conditional_formatting function""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) response = sheets_conditional_formatting.conditional_formatting( spreadsheet_id ) self.assertEqual(2, len(response.get("replies")))
11
66
87
153
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,274
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_create.py
23,24
20,30
test_create
Testsheetscreate
25,30
24,30
class Testsheetscreate(BaseTest): """Unit test class for Create Sheet snippet""" def test_create(self): FILL_FUNC_BODY
class Testsheetscreate(BaseTest): """Unit test class for Create Sheet snippet""" def test_create(self): """sheet function for Create sheet""" FILL_FUNC_BODY
spreadsheet_id = sheets_create.create("Title") self.assertIsNotNone(spreadsheet_id) self.delete_file_on_cleanup(spreadsheet_id)
"""sheet function for Create sheet""" spreadsheet_id = sheets_create.create("Title") self.assertIsNotNone(spreadsheet_id) self.delete_file_on_cleanup(spreadsheet_id)
5
53
56
109
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,275
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_filter_views.py
23,24
20,30
test_filter_views
Testfilterviews
25,30
24,30
class Testfilterviews(BaseTest): """Unit test for sheets conditional_formatting value Sheet snippet""" def test_filter_views(self): FILL_FUNC_BODY
class Testfilterviews(BaseTest): """Unit test for sheets conditional_formatting value Sheet snippet""" def test_filter_views(self): """test filter view function""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) sheets_filter_views.filter_views(spreadsheet_id)
"""test filter view function""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) sheets_filter_views.filter_views(spreadsheet_id)
5
57
57
114
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,276
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_get_values.py
23,24
20,35
test_get_values
Testgetvalues
25,35
24,35
class Testgetvalues(BaseTest): """Unit test class for get value Sheet snippet""" def test_get_values(self): FILL_FUNC_BODY
class Testgetvalues(BaseTest): """Unit test class for get value Sheet snippet""" def test_get_values(self): """test_get_values""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_get_values.get_values(spreadsheet_id, "A1:C2") self.assertIsNotNone(result) values = result.get("values") self.assertIsNotNone(values) self.assertEqual(2, len(values)) self.assertEqual(3,...
"""test_get_values""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) result = sheets_get_values.get_values(spreadsheet_id, "A1:C2") self.assertIsNotNone(result) values = result.get("values") self.assertIsNotNone(values) self.assertEqual(2, len(values...
17
55
129
184
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,277
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_pivot_tables.py
23,24
20,31
test_pivot_tables
Testpivottables
25,31
24,31
class Testpivottables(BaseTest): """Unit test for Pivot tables value Sheet snippet""" def test_pivot_tables(self): FILL_FUNC_BODY
class Testpivottables(BaseTest): """Unit test for Pivot tables value Sheet snippet""" def test_pivot_tables(self): """pivot table function""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) response = sheets_pivot_tables.pivot_tables(spreadsheet_id) self.assertIsNotNone(response)
"""pivot table function""" spreadsheet_id = self.create_test_spreadsheet() self.populate_values(spreadsheet_id) response = sheets_pivot_tables.pivot_tables(spreadsheet_id) self.assertIsNotNone(response)
8
58
73
131
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,278
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/sheets/snippets/test_sheets_update_values.py
23,24
20,35
test_update_values
Testupdatesvalues
25,35
24,35
class Testupdatesvalues(BaseTest): """Unit test for update value Sheet snippet""" def test_update_values(self): FILL_FUNC_BODY
class Testupdatesvalues(BaseTest): """Unit test for update value Sheet snippet""" def test_update_values(self): """test updates_values""" FILL_FUNC_BODY
spreadsheet_id = self.create_test_spreadsheet() result = sheets_update_values.update_values( spreadsheet_id, "A1:B2", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual(2, result.get("updatedRows")) self.assertEqual(2, result.get("updatedColumns")) ...
"""test updates_values""" spreadsheet_id = self.create_test_spreadsheet() result = sheets_update_values.update_values( spreadsheet_id, "A1:B2", "USER_ENTERED", [["A", "B"], ["C", "D"]] ) self.assertIsNotNone(result) self.assertEqual(2, result.get("updatedRows")) self.assertEqual(2, r...
21
53
138
191
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,279
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/quickstart/quickstart.py
31,32
1,76
main
35,73
32,73
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("token.json"): creds = Credentials.from_authorized_user_file("token.json", SCOPES) # If there are no (valid) creden...
"""Shows basic usage of the Slides API. Prints the number of slides and elements in a sample presentation. """ creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("tok...
130
402
438
840
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
47,280
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/base_test.py
54,55
24,170
tearDown
BaseTest
55,61
55,61
class BaseTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.credentials = cls.create_credentials() http = cls.credentials.authorize(httplib2.Http()) cls.credentials.refresh(http) cls.service = build("slides", "v1", http=http) cls.drive_service = build("drive", "v3", http=http) ...
class BaseTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.credentials = cls.create_credentials() http = cls.credentials.authorize(httplib2.Http()) cls.credentials.refresh(http) cls.service = build("slides", "v1", http=http) cls.drive_service = build("drive", "v3", http=http) ...
for file_id in self.files_to_delete: try: self.drive_service.files().delete(fileId=file_id).execute() except errors.HttpError: print(f"Unable to delete file {file_id}", file=sys.stderr)
for file_id in self.files_to_delete: try: self.drive_service.files().delete(fileId=file_id).execute() except errors.HttpError: print(f"Unable to delete file {file_id}", file=sys.stderr)
14
1,299
79
1,378
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
47,281
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_copy_presentation.py
23,24
1,54
copy_presentation
30,50
24,50
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: drive_service = build("drive", "v3", credentials=creds) body = {"name": copy_title} drive_response = ( drive_service.files().copy(fileId=presentation_id, body=body).execute() ) presentation_copy_id = drive_respons...
""" Creates the copy Presentation the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member...
44
366
192
558
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,282
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_bulleted_text.py
23,24
1,68
create_bulleted_text
30,60
24,60
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: slides_service = build("slides", "v1", credentials=creds) # Add arrow-diamond-disc bullets to all text in the shape. requests = [ { "createParagraphBullets": { "objectId": shape_id, ...
""" Run create_bulleted_text the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
76
385
288
673
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,283
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_image.py
23,24
1,86
create_image
30,81
24,81
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) # pylint: disable = invalid-name IMAGE_URL = ( "https://www.google.com/images/branding/" "googlelogo/2x/googlelogo_color_272x92dp.png" ) # pylint: disable...
""" Creates images the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: ser...
112
371
521
892
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,284
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_presentation.py
23,24
1,54
create_presentation
30,48
24,48
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) body = {"title": title} presentation = service.presentations().create(body=body).execute() print( f"Created presentation with ID:{(presentation.get('presentationId'))...
""" Creates the Presentation the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try...
41
315
163
478
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,285
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_sheets_chart.py
23,26
1,91
create_sheets_chart
32,80
26,80
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: slides_service = build("slides", "v1", credentials=creds) # Embed a Sheets chart (indicated by the spreadsheet_id and # sheet_chart_id) onto a page in the presentation. # Setting the linking mode as "LINKED" allows the # c...
""" create_sheets_chart the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: ...
136
473
508
981
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,286
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_slide.py
23,24
1,73
create_slide
30,68
24,68
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) # Add a slide at index 1 using the predefined # 'TITLE_AND_TWO_COLUMNS' layout and the ID page_id. requests = [ { "createSlide": { "objectI...
""" Creates the Presentation the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application.\n """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member t...
105
374
384
758
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,287
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_create_textbox_with_text.py
23,24
1,90
create_textbox_with_text
30,82
24,82
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) # Create a new square textbox, using the supplied element ID. element_id = "MyTextBox_10" pt350 = {"magnitude": 350, "unit": "PT"} requests = [ { "crea...
""" Creates the textbox with text, the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member...
129
401
509
910
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,288
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_image_merging.py
23,24
1,116
image_merging
30,105
24,105
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: slides_service = build("slides", "v1", credentials=creds) drive_service = build("drive", "v3", credentials=creds) logo_url = image_url customer_graphic_url = image_url # Duplicate the template presentation using the Driv...
"""image_merging require template_presentation_id, image_url and customer_name Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: dis...
170
438
696
1,134
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,289
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_refresh_sheets_chart.py
23,24
1,58
refresh_sheets_chart
30,51
24,51
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: slides_service = build("slides", "v1", credentials=creds) # Refresh an existing linked Sheets chart embedded in a presentation. requests = [{"refreshSheetsChart": {"objectId": presentation_chart_id}}] # Execute the request. ...
""" refresh_sheets_chart the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: ...
64
402
229
631
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,290
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_simple_text_replace.py
23,24
1,73
simple_text_replace
30,64
24,64
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: slides_service = build("slides", "v1", credentials=creds) # Remove existing text in the shape, then insert new text. requests = [] requests.append( {"deleteText": {"objectId": shape_id, "textRange": {"type": "ALL"}}} ...
""" Run simple_text_replace the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try:...
87
399
314
713
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,291
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_text_merging.py
23,24
1,130
text_merging
30,121
24,121
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) sheets_service = build("sheets", "v4", credentials=creds) drive_service = build("drive", "v3", credentials=creds) # Use the Sheets API to load data, one record per row. d...
""" Run Text merging the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: s...
244
428
889
1,317
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,292
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/slides_text_style_update.py
23,24
1,110
text_style_update
30,103
24,103
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: service = build("slides", "v1", credentials=creds) # Update the text style so that the first 5 characters are bolded # and italicized, the next 5 are displayed in blue 14 pt Times # New Roman font, and the next 5 are hyperlink...
""" create_sheets_chart the user has access to. Load pre-authorized user credentials from the environment. TODO(developer) - See https://developers.google.com/identity for guides on implementing OAuth2 for the application. """ creds, _ = google.auth.default() # pylint: disable=maybe-no-member try: ...
179
388
675
1,063
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
47,293
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_copy_presentation.py
23,24
20,33
test_copy_presentation
TestCopyPresentation
25,33
24,33
class TestCopyPresentation(BaseTest): """Unit test for Copy presentation snippet""" def test_copy_presentation(self): FILL_FUNC_BODY
class TestCopyPresentation(BaseTest): """Unit test for Copy presentation snippet""" def test_copy_presentation(self): """set title for copy presentation""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() copy_id = slides_copy_presentation.copy_presentation( presentation_id, "My Duplicate Presentation" ) self.assertIsNotNone(copy_id) self.delete_file_on_cleanup(copy_id)
"""set title for copy presentation""" presentation_id = self.create_test_presentation() copy_id = slides_copy_presentation.copy_presentation( presentation_id, "My Duplicate Presentation" ) self.assertIsNotNone(copy_id) self.delete_file_on_cleanup(copy_id)
13
55
89
144
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,294
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_bulleted_text.py
24,25
21,35
test_create_bulleted_text
TestCreateBulletedText
26,35
25,35
class TestCreateBulletedText(BaseTest): """Unit test for create_bulleted_text snippet""" def test_create_bulleted_text(self): FILL_FUNC_BODY
class TestCreateBulletedText(BaseTest): """Unit test for create_bulleted_text snippet""" def test_create_bulleted_text(self): """create_bulleted_text function""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_create_bulleted_text.create_bulleted_text( presentation_id, box_id ) self.assertEqual(1, len(response....
"""create_bulleted_text function""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_create_bulleted_text.create_bulleted_text( presentation_id, box_id ...
21
64
136
200
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,295
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_image.py
24,25
21,34
test_create_image
TestCreateTextboxWithText
26,34
25,34
class TestCreateTextboxWithText(BaseTest): """Unit test case for create_image snippet""" def test_create_image(self): FILL_FUNC_BODY
class TestCreateTextboxWithText(BaseTest): """Unit test case for create_image snippet""" def test_create_image(self): """presentation id and page id for create image""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_image.create_image(presentation_id, page_id) self.assertEqual(1, len(response.get("replies")), msg=pformat(response)) image_id = response.get("replies")[0].get("create...
"""presentation id and page id for create image""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_image.create_image(presentation_id, page_id) self.assertEqual(1, len(response.get("replies")), msg=pformat(response)...
20
61
148
209
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,296
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_presentation.py
23,24
20,30
test_create_presentation
TestCreatePresentation
25,30
24,30
class TestCreatePresentation(BaseTest): """Unit test for create presentation snippet""" def test_create_presentation(self): FILL_FUNC_BODY
class TestCreatePresentation(BaseTest): """Unit test for create presentation snippet""" def test_create_presentation(self): """Set title for create presentation""" FILL_FUNC_BODY
presentation = slides_create_presentation.create_presentation("Title") self.assertIsNotNone(presentation) self.delete_file_on_cleanup(presentation.get("presentationId"))
"""Set title for create presentation""" presentation = slides_create_presentation.create_presentation("Title") self.assertIsNotNone(presentation) self.delete_file_on_cleanup(presentation.get("presentationId"))
5
55
59
114
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,297
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_sheets_chart.py
27,28
21,41
test_create_sheets_chart
TestCreateSheetsChart
29,41
28,41
class TestCreateSheetsChart(BaseTest): """Unit test for create_sheets_chart snippet""" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" CHART_ID = 1107320627 def test_create_sheets_chart(self): FILL_FUNC_BODY
class TestCreateSheetsChart(BaseTest): """Unit test for create_sheets_chart snippet""" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" CHART_ID = 1107320627 def test_create_sheets_chart(self): """create_sheet chart method""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_sheets_chart.create_sheets_chart( presentation_id, page_id, self.DATA_SPREADSHEET_ID, self.CHART_ID ) self.assertEqual(1, len(response.get("replies")), msg=pfo...
"""create_sheet chart method""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_sheets_chart.create_sheets_chart( presentation_id, page_id, self.DATA_SPREADSHEET_ID, self.CHART_ID ) self.assertEqual(1, l...
26
132
188
320
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,298
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_slide.py
23,24
20,35
test_create_slide
TestCreateSlide
25,35
24,35
class TestCreateSlide(BaseTest): """Unit test for create Slide snippet""" def test_create_slide(self): FILL_FUNC_BODY
class TestCreateSlide(BaseTest): """Unit test for create Slide snippet""" def test_create_slide(self): """pass presentation_id and page_id for creating the slides""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() self.add_slides(presentation_id, 3) page_id = "my_page_id" response = slides_create_slide.create_slide(presentation_id, page_id) self.assertEqual( page_id, response.get("replies")[0].get("createSlide").get("objectId"), )
"""pass presentation_id and page_id for creating the slides""" presentation_id = self.create_test_presentation() self.add_slides(presentation_id, 3) page_id = "my_page_id" response = slides_create_slide.create_slide(presentation_id, page_id) self.assertEqual( page_id, response.ge...
16
62
118
180
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,299
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_create_textbox_with_text.py
24,25
21,36
test_create_textbox_with_text
TestCreateTextboxWithText
26,36
25,36
class TestCreateTextboxWithText(BaseTest): """Unit test for TestCreateTextboxWithText snippet""" def test_create_textbox_with_text(self): FILL_FUNC_BODY
class TestCreateTextboxWithText(BaseTest): """Unit test for TestCreateTextboxWithText snippet""" def test_create_textbox_with_text(self): """Pass Presentation id and page id""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_textbox_with_text.create_textbox_with_text( presentation_id, page_id ) self.assertEqual(2, len(response.get("replies")), msg=pformat(response)) box_id = re...
"""Pass Presentation id and page id""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] response = slides_create_textbox_with_text.create_textbox_with_text( presentation_id, page_id ) self.assertEqual(2, len(response.get("replies...
22
66
163
229
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,300
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_image_merging.py
30,31
21,47
test_image_merging
TestTextMerging
32,47
31,47
class TestTextMerging(BaseTest): """Unit test for text merging snippet""" TEMPLATE_PRESENTATION_ID = "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" IMAGE_URL = "https://picsum.photos/200" CHART_ID = 1107320627 CUSTOMER_NAME = "Fake Custom...
class TestTextMerging(BaseTest): """Unit test for text merging snippet""" TEMPLATE_PRESENTATION_ID = "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" IMAGE_URL = "https://picsum.photos/200" CHART_ID = 1107320627 CUSTOMER_NAME = "Fake Custom...
response = slides_image_merging.image_merging( self.TEMPLATE_PRESENTATION_ID, self.IMAGE_URL, self.CUSTOMER_NAME ) presentation_id = response.get("presentationId") self.delete_file_on_cleanup(presentation_id) self.assertIsNotNone(presentation_id, msg=pformat(response)) self.assertEqual(2...
"""image merging function""" response = slides_image_merging.image_merging( self.TEMPLATE_PRESENTATION_ID, self.IMAGE_URL, self.CUSTOMER_NAME ) presentation_id = response.get("presentationId") self.delete_file_on_cleanup(presentation_id) self.assertIsNotNone(presentation_id, msg=pformat(...
31
217
213
430
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,301
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_refresh_sheets_chart.py
27,28
21,40
test_refresh_sheets_chart
TestCreateSheetsChart
29,40
28,40
class TestCreateSheetsChart(BaseTest): """Unit test for refresh_sheets_chart snippet""" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" CHART_ID = 1107320627 def test_refresh_sheets_chart(self): FILL_FUNC_BODY
class TestCreateSheetsChart(BaseTest): """Unit test for refresh_sheets_chart snippet""" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" CHART_ID = 1107320627 def test_refresh_sheets_chart(self): """refresh_sheets_chart method""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] chart_id = self.create_test_sheets_chart( presentation_id, page_id, self.DATA_SPREADSHEET_ID, self.CHART_ID ) response = slides_refresh_sheets_chart.refresh_sheets_chart( prese...
"""refresh_sheets_chart method""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] chart_id = self.create_test_sheets_chart( presentation_id, page_id, self.DATA_SPREADSHEET_ID, self.CHART_ID ) response = slides_refresh_sheets_cha...
25
136
164
300
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,302
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_simple_text_replace.py
24,25
21,35
test_simple_text_replace
TestSimpleTextReplace
26,35
25,35
class TestSimpleTextReplace(BaseTest): """Unit test for SimpleTextReplace snippet""" def test_simple_text_replace(self): FILL_FUNC_BODY
class TestSimpleTextReplace(BaseTest): """Unit test for SimpleTextReplace snippet""" def test_simple_text_replace(self): """test_simple_text_replace function""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_simple_text_replace.simple_text_replace( presentation_id, box_id, "MY NEW TEXT" ) self.assertEqual(2, ...
"""test_simple_text_replace function""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_simple_text_replace.simple_text_replace( presentation_id, box_id, ...
24
59
141
200
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,303
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_text_merging.py
26,27
20,33
test_text_merging
TestTextMerging
28,33
27,33
class TestTextMerging(BaseTest): """Unit test for SimpleTextReplace snippet""" TEMPLATE_PRESENTATION_ID = "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" def test_text_merging(self): FILL_FUNC_BODY
class TestTextMerging(BaseTest): """Unit test for SimpleTextReplace snippet""" TEMPLATE_PRESENTATION_ID = "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4" DATA_SPREADSHEET_ID = "17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM" def test_text_merging(self): """text_merging method""" FILL_FUNC_BODY
slides_text_merging.text_merging( self.TEMPLATE_PRESENTATION_ID, self.DATA_SPREADSHEET_ID )
"""text_merging method""" slides_text_merging.text_merging( self.TEMPLATE_PRESENTATION_ID, self.DATA_SPREADSHEET_ID )
4
166
51
217
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,304
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/slides/snippets/test_slides_text_style_update.py
24,25
21,35
test_text_style_update
TestTextStyleUpdate
26,35
25,35
class TestTextStyleUpdate(BaseTest): """Unit test for SimpleTextReplace snippet""" def test_text_style_update(self): FILL_FUNC_BODY
class TestTextStyleUpdate(BaseTest): """Unit test for SimpleTextReplace snippet""" def test_text_style_update(self): """test_text_style_update function""" FILL_FUNC_BODY
presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_text_style_update.text_style_update( presentation_id, box_id ) self.assertEqual(3, len(response.get("r...
"""test_text_style_update function""" presentation_id = self.create_test_presentation() page_id = self.add_slides(presentation_id, 1, "BLANK")[0] box_id = self.create_test_textbox(presentation_id, page_id) response = slides_text_style_update.text_style_update( presentation_id, box_id ) ...
21
59
134
193
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
""" Copyright 2022 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
47,305
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/tasks/quickstart/quickstart.py
28,29
1,72
main
32,69
29,69
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("token.json"): creds = Credentials.from_authorized_user_file("token.json", SCOPES) # If there are no (valid) creden...
"""Shows basic usage of the Tasks API. Prints the title and ID of the first 10 task lists. """ creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("token.json"): c...
124
346
412
758
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
47,306
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples
/home/hieuvd/dung_repo/raw/stars_03/googleworkspace_python-samples/python-samples/vault/quickstart/quickstart.py
28,29
1,72
main
32,69
29,69
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("token.json"): creds = Credentials.from_authorized_user_file("token.json", SCOPES) # If there are no (valid) creden...
"""Shows basic usage of the Vault API. Prints the names and IDs of the first 10 matters in Vault. """ creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists("token.json")...
122
347
416
763
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
47,658
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/dataset/reseed.py
4,5
1,7
reseed
5,7
5,7
import torch import random def reseed(seed): FILL_FUNC_BODY
import torch import random def reseed(seed): FILL_FUNC_BODY
random.seed(seed) torch.manual_seed(seed)
random.seed(seed) torch.manual_seed(seed)
2
25
21
46
import torch import random def reseed(seed): FILL_FUNC_BODY
import torch import random def reseed(seed): FILL_FUNC_BODY
47,659
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/dataset/util.py
4,5
1,14
all_to_onehot
5,14
5,14
import numpy as np def all_to_onehot(masks, labels): FILL_FUNC_BODY
import numpy as np def all_to_onehot(masks, labels): FILL_FUNC_BODY
if len(masks.shape) == 3: Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1], masks.shape[2]), dtype=np.uint8) else: Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1]), dtype=np.uint8) for ni, l in enumerate(labels): Ms[ni] = (masks == l).astype(np.uint8) ...
if len(masks.shape) == 3: Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1], masks.shape[2]), dtype=np.uint8) else: Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1]), dtype=np.uint8) for ni, l in enumerate(labels): Ms[ni] = (masks == l).astype(np.uint8) ...
30
32
145
177
import numpy as np def all_to_onehot(masks, labels): FILL_FUNC_BODY
import numpy as np def all_to_onehot(masks, labels): FILL_FUNC_BODY
47,660
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/data/mask_mapper.py
26,27
7,65
convert_mask
MaskMapper
27,56
27,56
class MaskMapper: """ This class is used to convert a indexed-mask to a one-hot representation. It also takes care of remapping non-continuous indices It has two modes: 1. Default. Only masks with new indices are supposed to go into the remapper. This is also the case for YouTubeVOS. ...
class MaskMapper: """ This class is used to convert a indexed-mask to a one-hot representation. It also takes care of remapping non-continuous indices It has two modes: 1. Default. Only masks with new indices are supposed to go into the remapper. This is also the case for YouTubeVOS. ...
# mask is in index representation, H*W numpy array labels = np.unique(mask).astype(np.uint8) labels = labels[labels!=0].tolist() new_labels = list(set(labels) - set(self.labels)) if not exhaustive: assert len(new_labels) == len(labels), 'Old labels found in non-exhau...
# mask is in index representation, H*W numpy array labels = np.unique(mask).astype(np.uint8) labels = labels[labels!=0].tolist() new_labels = list(set(labels) - set(self.labels)) if not exhaustive: assert len(new_labels) == len(labels), 'Old labels found in non-exhau...
82
301
369
670
import numpy as np import torch from dataset.util import all_to_onehot class MaskMapper: """ This class is used to convert a indexed-mask to a one-hot representation. It also takes care of remapping non-continuous indices It has two modes: 1. Default. Only masks with new indices are supposed ...
import numpy as np import torch from dataset.util import all_to_onehot class MaskMapper: """ This class is used to convert a indexed-mask to a one-hot representation. It also takes care of remapping non-continuous indices It has two modes: 1. Default. Only masks with new indices are supposed ...
47,661
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/data/test_datasets.py
50,51
31,63
get_datasets
DAVISTestDataset
51,59
51,59
class DAVISTestDataset: def __init__(self, data_root, imset='2017/val.txt', size=-1): if size != 480: self.image_dir = path.join(data_root, 'JPEGImages', 'Full-Resolution') self.mask_dir = path.join(data_root, 'Annotations', 'Full-Resolution') if not path.exists(self.imag...
class DAVISTestDataset: def __init__(self, data_root, imset='2017/val.txt', size=-1): if size != 480: self.image_dir = path.join(data_root, 'JPEGImages', 'Full-Resolution') self.mask_dir = path.join(data_root, 'Annotations', 'Full-Resolution') if not path.exists(self.imag...
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), size=self.size, size_dir=path.join(self.size_dir, video), )
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), size=self.size, size_dir=path.join(self.size_dir, video), )
14
393
87
480
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
47,662
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/data/test_datasets.py
16,17
8,31
get_datasets
LongTestDataset
17,27
17,27
class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size self.vid_list = sorted(os.listdir(self.image_dir)) def get_datasets(self): FILL_FUNC_BODY d...
class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size self.vid_list = sorted(os.listdir(self.image_dir)) def get_datasets(self): FILL_FUNC_BODY d...
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), to_save = [ name[:-4] for name in os.listdir(path.join(self.mask_dir, video)) ], ...
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), to_save = [ name[:-4] for name in os.listdir(path.join(self.mask_dir, video)) ], ...
22
138
108
246
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
47,663
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/data/test_datasets.py
85,86
63,97
get_datasets
YouTubeVOSTestDataset
86,95
86,95
class YouTubeVOSTestDataset: def __init__(self, data_root, split, size=480): self.image_dir = path.join(data_root, 'all_frames', split+'_all_frames', 'JPEGImages') self.mask_dir = path.join(data_root, split, 'Annotations') self.size = size self.vid_list = sorted(os.listdir(self.imag...
class YouTubeVOSTestDataset: def __init__(self, data_root, split, size=480): self.image_dir = path.join(data_root, 'all_frames', split+'_all_frames', 'JPEGImages') self.mask_dir = path.join(data_root, split, 'Annotations') self.size = size self.vid_list = sorted(os.listdir(self.imag...
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), size=self.size, to_save=self.req_frame_list[video], use_all_mask=True )
for video in self.vid_list: yield VideoReader(video, path.join(self.image_dir, video), path.join(self.mask_dir, video), size=self.size, to_save=self.req_frame_list[video], use_all_mask=True )
14
302
96
398
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
import os from os import path import json from inference.data.video_reader import VideoReader class LongTestDataset: def __init__(self, data_root, size=-1): self.image_dir = path.join(data_root, 'JPEGImages') self.mask_dir = path.join(data_root, 'Annotations') self.size = size se...
47,664
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/data/video_reader.py
89,90
14,101
resize_mask
VideoReader
90,96
90,96
class VideoReader(Dataset): """ This class is used to read a video, one frame at a time """ def __init__(self, vid_name, image_dir, mask_dir, size=-1, to_save=None, use_all_mask=False, size_dir=None): """ image_dir - points to a directory of jpg images mask_dir - points to a dire...
class VideoReader(Dataset): """ This class is used to read a video, one frame at a time """ def __init__(self, vid_name, image_dir, mask_dir, size=-1, to_save=None, use_all_mask=False, size_dir=None): """ image_dir - points to a directory of jpg images mask_dir - points to a dire...
# mask transform is applied AFTER mapper, so we need to post-process it in eval.py h, w = mask.shape[-2:] min_hw = min(h, w) return F.interpolate(mask, (int(h/min_hw*self.size), int(w/min_hw*self.size)), mode='nearest')
# mask transform is applied AFTER mapper, so we need to post-process it in eval.py h, w = mask.shape[-2:] min_hw = min(h, w) return F.interpolate(mask, (int(h/min_hw*self.size), int(w/min_hw*self.size)), mode='nearest')
28
910
101
1,011
import os from os import path from torch.utils.data.dataset import Dataset from torchvision import transforms from torchvision.transforms import InterpolationMode import torch.nn.functional as F from PIL import Image import numpy as np from dataset.range_transform import im_normalization class VideoReader(Dataset):...
import os from os import path from torch.utils.data.dataset import Dataset from torchvision import transforms from torchvision.transforms import InterpolationMode import torch.nn.functional as F from PIL import Image import numpy as np from dataset.range_transform import im_normalization class VideoReader(Dataset):...
47,665
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/inference_core.py
22,23
8,108
clear_memory
InferenceCore
23,29
23,29
class InferenceCore: def __init__(self, network:XMem, config): self.config = config self.network = network self.mem_every = config['mem_every'] self.deep_update_every = config['deep_update_every'] self.enable_long_term = config['enable_long_term'] # if deep_update_ev...
class InferenceCore: def __init__(self, network:XMem, config): self.config = config self.network = network self.mem_every = config['mem_every'] self.deep_update_every = config['deep_update_every'] self.enable_long_term = config['enable_long_term'] # if deep_update_ev...
self.curr_ti = -1 self.last_mem_ti = 0 if not self.deep_update_sync: self.last_deep_update_ti = -self.deep_update_every self.memory = MemoryManager(config=self.config)
self.curr_ti = -1 self.last_mem_ti = 0 if not self.deep_update_sync: self.last_deep_update_ti = -self.deep_update_every self.memory = MemoryManager(config=self.config)
15
1,399
76
1,475
from inference.memory_manager import MemoryManager from model.network import XMem from model.aggregate import aggregate from util.tensor_util import pad_divide_by, unpad class InferenceCore: def __init__(self, network:XMem, config): self.config = config self.network = network self.mem_eve...
from inference.memory_manager import MemoryManager from model.network import XMem from model.aggregate import aggregate from util.tensor_util import pad_divide_by, unpad class InferenceCore: def __init__(self, network:XMem, config): self.config = config self.network = network self.mem_eve...
47,666
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/controller.py
27,28
11,111
set_image
InteractiveController
28,33
28,33
class InteractiveController: def __init__(self, net, device, predictor_params, prob_thresh=0.5): self.net = net.to(device) self.prob_thresh = prob_thresh self.clicker = clicker.Clicker() self.states = [] self.probs_history = [] self.object_count = 0 self._resu...
class InteractiveController: def __init__(self, net, device, predictor_params, prob_thresh=0.5): self.net = net.to(device) self.prob_thresh = prob_thresh self.clicker = clicker.Clicker() self.states = [] self.probs_history = [] self.object_count = 0 self._resu...
self.image = image self._result_mask = torch.zeros(image.shape[-2:], dtype=torch.uint8) self.object_count = 0 self.reset_last_object()
self.image = image self._result_mask = torch.zeros(image.shape[-2:], dtype=torch.uint8) self.object_count = 0 self.reset_last_object()
11
957
62
1,019
import torch try: from torch import mps except: pass from ..fbrs.inference import clicker from ..fbrs.inference.predictors import get_predictor class InteractiveController: def __init__(self, net, device, predictor_params, prob_thresh=0.5): self.net = net.to(device) self.prob_thresh = pro...
import torch try: from torch import mps except: pass from ..fbrs.inference import clicker from ..fbrs.inference.predictors import get_predictor class InteractiveController: def __init__(self, net, device, predictor_params, prob_thresh=0.5): self.net = net.to(device) self.prob_thresh = pro...
47,667
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/evaluation.py
16,17
1,57
evaluate_dataset
17,36
17,36
from time import time import numpy as np import torch from ..inference import utils from ..inference.clicker import Clicker try: get_ipython() from tqdm import tqdm_notebook as tqdm except NameError: from tqdm import tqdm def evaluate_dataset(dataset, predictor, oracle_eval=False, **kwargs): FILL_FUNC_...
from time import time import numpy as np import torch from ..inference import utils from ..inference.clicker import Clicker try: get_ipython() from tqdm import tqdm_notebook as tqdm except NameError: from tqdm import tqdm def evaluate_dataset(dataset, predictor, oracle_eval=False, **kwargs): FILL_FUNC_...
all_ious = [] start_time = time() for index in tqdm(range(len(dataset)), leave=False): sample = dataset.get_sample(index) item = dataset[index] if oracle_eval: gt_mask = torch.tensor(sample['instances_mask'], dtype=torch.float32) gt_mask = gt_mask.unsqueeze(...
all_ious = [] start_time = time() for index in tqdm(range(len(dataset)), leave=False): sample = dataset.get_sample(index) item = dataset[index] if oracle_eval: gt_mask = torch.tensor(sample['instances_mask'], dtype=torch.float32) gt_mask = gt_mask.unsqueeze(...
47
370
239
609
from time import time import numpy as np import torch from ..inference import utils from ..inference.clicker import Clicker try: get_ipython() from tqdm import tqdm_notebook as tqdm except NameError: from tqdm import tqdm def evaluate_dataset(dataset, predictor, oracle_eval=False, **kwargs): FILL_FUNC_...
from time import time import numpy as np import torch from ..inference import utils from ..inference.clicker import Clicker try: get_ipython() from tqdm import tqdm_notebook as tqdm except NameError: from tqdm import tqdm def evaluate_dataset(dataset, predictor, oracle_eval=False, **kwargs): FILL_FUNC_...
47,668
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/base.py
76,77
7,101
get_points_nd
BasePredictor
77,96
77,96
class BasePredictor(object): def __init__(self, net, device, net_clicks_limit=None, with_flip=False, zoom_in=None, max_size=None, **kwargs): self.net = net self.with_flip = with_flip self.net_clicks_limit = ...
class BasePredictor(object): def __init__(self, net, device, net_clicks_limit=None, with_flip=False, zoom_in=None, max_size=None, **kwargs): self.net = net self.with_flip = with_flip self.net_clicks_limit = ...
total_clicks = [] num_pos_clicks = [sum(x.is_positive for x in clicks_list) for clicks_list in clicks_lists] num_neg_clicks = [len(clicks_list) - num_pos for clicks_list, num_pos in zip(clicks_lists, num_pos_clicks)] num_max_points = max(num_pos_clicks + num_neg_clicks) if self.n...
total_clicks = [] num_pos_clicks = [sum(x.is_positive for x in clicks_list) for clicks_list in clicks_lists] num_neg_clicks = [len(clicks_list) - num_pos for clicks_list, num_pos in zip(clicks_lists, num_pos_clicks)] num_max_points = max(num_pos_clicks + num_neg_clicks) if self.n...
95
874
387
1,261
import torch import torch.nn.functional as F from ..transforms import AddHorizontalFlip, SigmoidForPred, LimitLongestSide class BasePredictor(object): def __init__(self, net, device, net_clicks_limit=None, with_flip=False, zoom_in=None, max_size...
import torch import torch.nn.functional as F from ..transforms import AddHorizontalFlip, SigmoidForPred, LimitLongestSide class BasePredictor(object): def __init__(self, net, device, net_clicks_limit=None, with_flip=False, zoom_in=None, max_size...
47,669
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/brs_functors.py
33,34
8,83
init_click
BaseOptimizer
34,41
34,41
class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(), with_flip=False, flip_average=False, **kwargs): self....
class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(), with_flip=False, flip_average=False, **kwargs): self....
self.best_prediction = None self._get_prediction_logits = get_prediction_logits self._click_masks = (pos_mask, neg_mask) self._opt_shape = shape self._last_mask = None self.device = device
self.best_prediction = None self._get_prediction_logits = get_prediction_logits self._click_masks = (pos_mask, neg_mask) self._opt_shape = shape self._last_mask = None self.device = device
19
903
80
983
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
47,670
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/brs_functors.py
84,85
83,94
unpack_opt_params
InputOptimizer
85,94
85,94
class InputOptimizer(BaseOptimizer): def unpack_opt_params(self, opt_params): FILL_FUNC_BODY
class InputOptimizer(BaseOptimizer): def unpack_opt_params(self, opt_params): FILL_FUNC_BODY
opt_params = opt_params.view(self._opt_shape) if self.with_flip: opt_params_flipped = torch.flip(opt_params, dims=[3]) opt_params = torch.cat([opt_params, opt_params_flipped], dim=0) reg_loss = self.reg_weight * torch.sum(opt_params**2) return (opt_params,), reg_...
opt_params = opt_params.view(self._opt_shape) if self.with_flip: opt_params_flipped = torch.flip(opt_params, dims=[3]) opt_params = torch.cat([opt_params, opt_params_flipped], dim=0) reg_loss = self.reg_weight * torch.sum(opt_params**2) return (opt_params,), reg_...
22
37
126
163
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
47,671
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/brs_functors.py
100,101
94,110
unpack_opt_params
ScaleBiasOptimizer
101,110
101,110
class ScaleBiasOptimizer(BaseOptimizer): def __init__(self, *args, scale_act=None, reg_bias_weight=10.0, **kwargs): super().__init__(*args, **kwargs) self.scale_act = scale_act self.reg_bias_weight = reg_bias_weight def unpack_opt_params(self, opt_params): FILL_FUNC_BODY
class ScaleBiasOptimizer(BaseOptimizer): def __init__(self, *args, scale_act=None, reg_bias_weight=10.0, **kwargs): super().__init__(*args, **kwargs) self.scale_act = scale_act self.reg_bias_weight = reg_bias_weight def unpack_opt_params(self, opt_params): FILL_FUNC_BODY
scale, bias = torch.chunk(opt_params, 2, dim=0) reg_loss = self.reg_weight * (torch.sum(scale**2) + self.reg_bias_weight * torch.sum(bias**2)) if self.scale_act == 'tanh': scale = torch.tanh(scale) elif self.scale_act == 'sin': scale = torch.sin(scale) r...
scale, bias = torch.chunk(opt_params, 2, dim=0) reg_loss = self.reg_weight * (torch.sum(scale**2) + self.reg_bias_weight * torch.sum(bias**2)) if self.scale_act == 'tanh': scale = torch.tanh(scale) elif self.scale_act == 'sin': scale = torch.sin(scale) r...
35
114
137
251
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
import torch import numpy as np from ...model.metrics import _compute_iou from .brs_losses import BRSMaskLoss class BaseOptimizer: def __init__(self, optimizer_params, prob_thresh=0.49, reg_weight=1e-3, min_iou_diff=0.01, brs_loss=BRSMaskLoss(),...
47,672
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/brs_losses.py
11,12
6,29
forward
BRSMaskLoss
12,29
12,29
class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): FILL_FUNC_BODY
class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): FILL_FUNC_BODY
pos_diff = (1 - result) * pos_mask pos_target = torch.sum(pos_diff ** 2) pos_target = pos_target / (torch.sum(pos_mask) + self._eps) neg_diff = result * neg_mask neg_target = torch.sum(neg_diff ** 2) neg_target = neg_target / (torch.sum(neg_mask) + self._eps) ...
pos_diff = (1 - result) * pos_mask pos_target = torch.sum(pos_diff ** 2) pos_target = pos_target / (torch.sum(pos_mask) + self._eps) neg_diff = result * neg_mask neg_target = torch.sum(neg_diff ** 2) neg_target = neg_target / (torch.sum(neg_mask) + self._eps) ...
53
75
221
296
import torch from ...model.losses import SigmoidBinaryCrossEntropyLoss class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): FILL_FUNC_BODYclass OracleMaskLoss(torch.nn.Module): def __init__(sel...
import torch from ...model.losses import SigmoidBinaryCrossEntropyLoss class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): FILL_FUNC_BODYclass OracleMaskLoss(torch.nn.Module): def __init__(sel...
47,673
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/predictors/brs_losses.py
41,42
29,59
forward
OracleMaskLoss
42,59
42,59
class OracleMaskLoss(torch.nn.Module): def __init__(self): super().__init__() self.gt_mask = None self.loss = SigmoidBinaryCrossEntropyLoss(from_sigmoid=True) self.predictor = None self.history = [] def set_gt_mask(self, gt_mask): self.gt_mask = gt_mask s...
class OracleMaskLoss(torch.nn.Module): def __init__(self): super().__init__() self.gt_mask = None self.loss = SigmoidBinaryCrossEntropyLoss(from_sigmoid=True) self.predictor = None self.history = [] def set_gt_mask(self, gt_mask): self.gt_mask = gt_mask s...
gt_mask = self.gt_mask.to(result.device) if self.predictor.object_roi is not None: r1, r2, c1, c2 = self.predictor.object_roi[:4] gt_mask = gt_mask[:, :, r1:r2 + 1, c1:c2 + 1] gt_mask = torch.nn.functional.interpolate(gt_mask, result.size()[2:], mode='bilinear', alig...
gt_mask = self.gt_mask.to(result.device) if self.predictor.object_roi is not None: r1, r2, c1, c2 = self.predictor.object_roi[:4] gt_mask = gt_mask[:, :, r1:r2 + 1, c1:c2 + 1] gt_mask = torch.nn.functional.interpolate(gt_mask, result.size()[2:], mode='bilinear', alig...
66
142
321
463
import torch from ...model.losses import SigmoidBinaryCrossEntropyLoss class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): pos_diff = (1 - result) * pos_mask pos_target = torch.sum...
import torch from ...model.losses import SigmoidBinaryCrossEntropyLoss class BRSMaskLoss(torch.nn.Module): def __init__(self, eps=1e-5): super().__init__() self._eps = eps def forward(self, result, pos_mask, neg_mask): pos_diff = (1 - result) * pos_mask pos_target = torch.sum...
47,674
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/transforms/base.py
8,9
4,24
transform
BaseTransform
9,11
9,11
class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError def get_state(self): raise...
class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError def get_state(self): raise...
raise NotImplementedError
raise NotImplementedError
2
128
11
139
import torch class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError def get_state(self)...
import torch class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError def get_state(self)...
47,675
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/transforms/base.py
25,26
24,39
transform
SigmoidForPred
26,28
26,28
class SigmoidForPred(BaseTransform): def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): return torch.sigmoid(prob_map) def reset(self): pass def get_state(self): return None def set_state(self, state): pass
class SigmoidForPred(BaseTransform): def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY def inv_transform(self, prob_map): return torch.sigmoid(prob_map) def reset(self): pass def get_state(self): return None def set_state(self, state): pass
return image_nd, clicks_lists
return image_nd, clicks_lists
3
104
14
118
import torch class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): raise NotImplementedError def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError ...
import torch class BaseTransform(object): def __init__(self): self.image_changed = False def transform(self, image_nd, clicks_lists): raise NotImplementedError def inv_transform(self, prob_map): raise NotImplementedError def reset(self): raise NotImplementedError ...
47,676
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/transforms/flip.py
23,24
7,38
inv_transform
AddHorizontalFlip
24,30
24,30
class AddHorizontalFlip(BaseTransform): def transform(self, image_nd, clicks_lists): assert len(image_nd.shape) == 4 image_nd = torch.cat([image_nd, torch.flip(image_nd, dims=[3])], dim=0) image_width = image_nd.shape[3] clicks_lists_flipped = [] for clicks_list in clicks_li...
class AddHorizontalFlip(BaseTransform): def transform(self, image_nd, clicks_lists): assert len(image_nd.shape) == 4 image_nd = torch.cat([image_nd, torch.flip(image_nd, dims=[3])], dim=0) image_width = image_nd.shape[3] clicks_lists_flipped = [] for clicks_list in clicks_li...
assert len(prob_map.shape) == 4 and prob_map.shape[0] % 2 == 0 num_maps = prob_map.shape[0] // 2 prob_map, prob_map_flipped = prob_map[:num_maps], prob_map[num_maps:] return 0.5 * (prob_map + torch.flip(prob_map_flipped, dims=[3]))
assert len(prob_map.shape) == 4 and prob_map.shape[0] % 2 == 0 num_maps = prob_map.shape[0] // 2 prob_map, prob_map_flipped = prob_map[:num_maps], prob_map[num_maps:] return 0.5 * (prob_map + torch.flip(prob_map_flipped, dims=[3]))
27
290
113
403
import torch from ..clicker import Click from .base import BaseTransform class AddHorizontalFlip(BaseTransform): def transform(self, image_nd, clicks_lists): assert len(image_nd.shape) == 4 image_nd = torch.cat([image_nd, torch.flip(image_nd, dims=[3])], dim=0) image_width = image_nd.sha...
import torch from ..clicker import Click from .base import BaseTransform class AddHorizontalFlip(BaseTransform): def transform(self, image_nd, clicks_lists): assert len(image_nd.shape) == 4 image_nd = torch.cat([image_nd, torch.flip(image_nd, dims=[3])], dim=0) image_width = image_nd.sha...
47,677
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/transforms/limit_longest_side.py
8,9
4,23
transform
LimitLongestSide
9,23
9,23
class LimitLongestSide(ZoomIn): def __init__(self, max_size=800): super().__init__(target_size=max_size, skip_clicks=0) def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY
class LimitLongestSide(ZoomIn): def __init__(self, max_size=800): super().__init__(target_size=max_size, skip_clicks=0) def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY
assert image_nd.shape[0] == 1 and len(clicks_lists) == 1 image_max_size = max(image_nd.shape[2:4]) self.image_changed = False if image_max_size <= self.target_size: return image_nd, clicks_lists self._input_image = image_nd self._object_roi = (0, image_nd.sh...
assert image_nd.shape[0] == 1 and len(clicks_lists) == 1 image_max_size = max(image_nd.shape[2:4]) self.image_changed = False if image_max_size <= self.target_size: return image_nd, clicks_lists self._input_image = image_nd self._object_roi = (0, image_nd.sh...
48
77
228
305
from .zoom_in import ZoomIn, get_roi_image_nd class LimitLongestSide(ZoomIn): def __init__(self, max_size=800): super().__init__(target_size=max_size, skip_clicks=0) def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY
from .zoom_in import ZoomIn, get_roi_image_nd class LimitLongestSide(ZoomIn): def __init__(self, max_size=800): super().__init__(target_size=max_size, skip_clicks=0) def transform(self, image_nd, clicks_lists): FILL_FUNC_BODY
47,679
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/inference/transforms/zoom_in.py
65,66
8,127
inv_transform
ZoomIn
66,85
66,85
class ZoomIn(BaseTransform): def __init__(self, target_size=400, skip_clicks=1, expansion_ratio=1.4, min_crop_size=200, recompute_thresh_iou=0.5, prob_thresh=0.50): super().__init__() self.target_si...
class ZoomIn(BaseTransform): def __init__(self, target_size=400, skip_clicks=1, expansion_ratio=1.4, min_crop_size=200, recompute_thresh_iou=0.5, prob_thresh=0.50): super().__init__() self.target_si...
if self._object_roi is None: self._prev_probs = prob_map.cpu().numpy() return prob_map assert prob_map.shape[0] == 1 rmin, rmax, cmin, cmax = self._object_roi prob_map = torch.nn.functional.interpolate(prob_map, size=(rmax - rmin + 1, cmax - cmin + 1), ...
if self._object_roi is None: self._prev_probs = prob_map.cpu().numpy() return prob_map assert prob_map.shape[0] == 1 rmin, rmax, cmin, cmax = self._object_roi prob_map = torch.nn.functional.interpolate(prob_map, size=(rmax - rmin + 1, cmax - cmin + 1), ...
63
1,309
282
1,591
import torch from ..clicker import Click from ...utils.misc import get_bbox_iou, get_bbox_from_mask, expand_bbox, clamp_bbox from .base import BaseTransform class ZoomIn(BaseTransform): def __init__(self, target_size=400, skip_clicks=1, expansion_ratio=1.4, ...
import torch from ..clicker import Click from ...utils.misc import get_bbox_iou, get_bbox_from_mask, expand_bbox, clamp_bbox from .base import BaseTransform class ZoomIn(BaseTransform): def __init__(self, target_size=400, skip_clicks=1, expansion_ratio=1.4, ...
47,681
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/initializer.py
66,68
47,79
get_bilinear_kernel
Bilinear
69,79
68,79
class Bilinear(Initializer): def __init__(self, scale, groups, in_channels, **kwargs): super().__init__(**kwargs) self.scale = scale self.groups = groups self.in_channels = in_channels def _init_weight(self, data): """Reset the weight and bias.""" bilinear_kernel...
class Bilinear(Initializer): def __init__(self, scale, groups, in_channels, **kwargs): super().__init__(**kwargs) self.scale = scale self.groups = groups self.in_channels = in_channels def _init_weight(self, data): """Reset the weight and bias.""" bilinear_kernel...
kernel_size = 2 * scale - scale % 2 scale = (kernel_size + 1) // 2 center = scale - 0.5 * (1 + kernel_size % 2) og = np.ogrid[:kernel_size, :kernel_size] kernel = (1 - np.abs(og[0] - center) / scale) * (1 - np.abs(og[1] - center) / scale) return torch.tensor(kernel, dty...
"""Generate a bilinear upsampling kernel.""" kernel_size = 2 * scale - scale % 2 scale = (kernel_size + 1) // 2 center = scale - 0.5 * (1 + kernel_size % 2) og = np.ogrid[:kernel_size, :kernel_size] kernel = (1 - np.abs(og[0] - center) / scale) * (1 - np.abs(og[1] - cent...
51
228
141
369
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
47,682
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/initializer.py
37,38
6,47
_init_gamma
Initializer
38,43
38,43
class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d, ...
class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d, ...
if self.gamma is None: nn.init.constant_(data, 1.0) else: nn.init.normal_(data, 1.0, self.gamma)
if self.gamma is None: nn.init.constant_(data, 1.0) else: nn.init.normal_(data, 1.0, self.gamma)
10
420
55
475
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
47,683
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/initializer.py
87,88
79,106
_init_weight
XavierGluon
88,106
88,106
class XavierGluon(Initializer): def __init__(self, rnd_type='uniform', factor_type='avg', magnitude=3, **kwargs): super().__init__(**kwargs) self.rnd_type = rnd_type self.factor_type = factor_type self.magnitude = float(magnitude) def _init_weight(self, arr): FILL_FUNC_BODY
class XavierGluon(Initializer): def __init__(self, rnd_type='uniform', factor_type='avg', magnitude=3, **kwargs): super().__init__(**kwargs) self.rnd_type = rnd_type self.factor_type = factor_type self.magnitude = float(magnitude) def _init_weight(self, arr): FILL_FUNC_BODY
fan_in, fan_out = nn.init._calculate_fan_in_and_fan_out(arr) if self.factor_type == 'avg': factor = (fan_in + fan_out) / 2.0 elif self.factor_type == 'in': factor = fan_in elif self.factor_type == 'out': factor = fan_out else: rais...
fan_in, fan_out = nn.init._calculate_fan_in_and_fan_out(arr) if self.factor_type == 'avg': factor = (fan_in + fan_out) / 2.0 elif self.factor_type == 'in': factor = fan_in elif self.factor_type == 'out': factor = fan_out else: rais...
58
114
223
337
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
import torch import torch.nn as nn import numpy as np class Initializer(object): def __init__(self, local_init=True, gamma=None): self.local_init = local_init self.gamma = gamma def __call__(self, m): if getattr(m, '__initialized', False): return if isinstance(m, ...
47,684
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/is_deeplab_model.py
9,13
1,87
get_deeplab_model
13,30
13,30
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
model = DistMapsModel( feature_extractor=DeepLabV3Plus(backbone=backbone, ch=deeplab_ch, project_dropout=aspp_dropout, norm_layer=norm_layer, backbo...
model = DistMapsModel( feature_extractor=DeepLabV3Plus(backbone=backbone, ch=deeplab_ch, project_dropout=aspp_dropout, norm_layer=norm_layer, backbo...
22
885
210
1,095
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
47,685
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/is_deeplab_model.py
68,69
30,87
load_weights
DistMapsModel
69,74
69,74
class DistMapsModel(nn.Module): def __init__(self, feature_extractor, head, norm_layer=nn.BatchNorm2d, use_rgb_conv=True, cpu_dist_maps=False, norm_radius=260): super(DistMapsModel, self).__init__() if use_rgb_conv: self.rgb_conv = nn.Sequential( nn.Conv...
class DistMapsModel(nn.Module): def __init__(self, feature_extractor, head, norm_layer=nn.BatchNorm2d, use_rgb_conv=True, cpu_dist_maps=False, norm_radius=260): super(DistMapsModel, self).__init__() if use_rgb_conv: self.rgb_conv = nn.Sequential( nn.Conv...
current_state_dict = self.state_dict() new_state_dict = torch.load(path_to_weights, map_location='cpu') current_state_dict.update(new_state_dict) self.load_state_dict(current_state_dict)
current_state_dict = self.state_dict() new_state_dict = torch.load(path_to_weights, map_location='cpu') current_state_dict.update(new_state_dict) self.load_state_dict(current_state_dict)
9
661
79
740
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.deeplab_v3 import DeepLabV3Plus from .modeling.basic_blocks import SepConvHead def get_deeplab_model(backbone='resnet50', deeplab_ch=256, aspp_dropout=0.5, norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ...
47,686
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/is_hrnet_model.py
8,11
1,88
get_hrnet_model
11,24
11,24
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
model = DistMapsHRNetModel( feature_extractor=HighResolutionNet(width=width, ocr_width=ocr_width, small=small, num_classes=1, norm_layer=norm_layer), use_rgb_conv=use_rgb_conv, with_aux_output=with_aux_output, norm_layer=norm_layer, ...
model = DistMapsHRNetModel( feature_extractor=HighResolutionNet(width=width, ocr_width=ocr_width, small=small, num_classes=1, norm_layer=norm_layer), use_rgb_conv=use_rgb_conv, with_aux_output=with_aux_output, norm_layer=norm_layer, ...
16
1,045
143
1,188
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
47,687
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/is_hrnet_model.py
43,44
24,88
forward
DistMapsHRNetModel
44,67
44,67
class DistMapsHRNetModel(nn.Module): def __init__(self, feature_extractor, use_rgb_conv=True, with_aux_output=False, norm_layer=nn.BatchNorm2d, norm_radius=260, cpu_dist_maps=False): super(DistMapsHRNetModel, self).__init__() self.with_aux_output = with_aux_output if use_rg...
class DistMapsHRNetModel(nn.Module): def __init__(self, feature_extractor, use_rgb_conv=True, with_aux_output=False, norm_layer=nn.BatchNorm2d, norm_radius=260, cpu_dist_maps=False): super(DistMapsHRNetModel, self).__init__() self.with_aux_output = with_aux_output if use_rg...
coord_features = self.dist_maps(image, points) if self.rgb_conv is not None: x = self.rgb_conv(torch.cat((image, coord_features), dim=1)) else: c1, c2 = torch.chunk(coord_features, 2, dim=1) c3 = torch.ones_like(c1) coord_features = torch.cat((c1,...
coord_features = self.dist_maps(image, points) if self.rgb_conv is not None: x = self.rgb_conv(torch.cat((image, coord_features), dim=1)) else: c1, c2 = torch.chunk(coord_features, 2, dim=1) c3 = torch.ones_like(c1) coord_features = torch.cat((c1,...
73
591
362
953
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
import torch import torch.nn as nn from .ops import DistMaps from .modeling.hrnet_ocr import HighResolutionNet def get_hrnet_model(width=48, ocr_width=256, small=False, norm_radius=260, use_rgb_conv=True, with_aux_output=False, cpu_dist_maps=False, norm_layer=nn.BatchNorm2d): ...
47,688
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/losses.py
88,89
70,113
forward
FocalLoss
89,113
89,113
class FocalLoss(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, num_class=None, eps=1e-9, size_average=True, scale=1.0): super(FocalLoss, self).__init__() self._axis = axis self._alp...
class FocalLoss(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, num_class=None, eps=1e-9, size_average=True, scale=1.0): super(FocalLoss, self).__init__() self._axis = axis self._alp...
if not self._from_logits: pred = F.sigmoid(pred) one_hot = label > 0 pt = torch.where(one_hot, pred, 1 - pred) t = label != -1 alpha = torch.where(one_hot, self._alpha * t, (1 - self._alpha) * t) beta = (1 - pt) ** self._gamma loss = -alpha * beta *...
if not self._from_logits: pred = F.sigmoid(pred) one_hot = label > 0 pt = torch.where(one_hot, pred, 1 - pred) t = label != -1 alpha = torch.where(one_hot, self._alpha * t, (1 - self._alpha) * t) beta = (1 - pt) ** self._gamma loss = -alpha * beta *...
92
230
351
581
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
47,689
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/losses.py
30,31
9,70
forward
NormalizedFocalLossSigmoid
31,66
31,66
class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_delimeter=True, eps=1e-12, scale=1.0, ignore_label=-1): super(NormalizedFo...
class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_delimeter=True, eps=1e-12, scale=1.0, ignore_label=-1): super(NormalizedFo...
one_hot = label > 0 sample_weight = label != self._ignore_label if not self._from_logits: pred = torch.sigmoid(pred) alpha = torch.where(one_hot, self._alpha * sample_weight, (1 - self._alpha) * sample_weight) pt = torch.where(one_hot, pred, 1 - pred) pt = t...
one_hot = label > 0 sample_weight = label != self._ignore_label if not self._from_logits: pred = torch.sigmoid(pred) alpha = torch.where(one_hot, self._alpha * sample_weight, (1 - self._alpha) * sample_weight) pt = torch.where(one_hot, pred, 1 - pred) pt = t...
146
327
607
934
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
47,690
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/losses.py
121,122
113,135
forward
SigmoidBinaryCrossEntropyLoss
122,135
122,135
class SigmoidBinaryCrossEntropyLoss(nn.Module): def __init__(self, from_sigmoid=False, weight=None, batch_axis=0, ignore_label=-1): super(SigmoidBinaryCrossEntropyLoss, self).__init__() self._from_sigmoid = from_sigmoid self._ignore_label = ignore_label self._weight = weight if weigh...
class SigmoidBinaryCrossEntropyLoss(nn.Module): def __init__(self, from_sigmoid=False, weight=None, batch_axis=0, ignore_label=-1): super(SigmoidBinaryCrossEntropyLoss, self).__init__() self._from_sigmoid = from_sigmoid self._ignore_label = ignore_label self._weight = weight if weigh...
label = label.view(pred.size()) sample_weight = label != self._ignore_label label = torch.where(sample_weight, label, torch.zeros_like(label)) if not self._from_sigmoid: loss = torch.relu(pred) - pred * label + F.softplus(-torch.abs(pred)) else: eps = 1e-...
label = label.view(pred.size()) sample_weight = label != self._ignore_label label = torch.where(sample_weight, label, torch.zeros_like(label)) if not self._from_sigmoid: loss = torch.relu(pred) - pred * label + F.softplus(-torch.abs(pred)) else: eps = 1e-...
57
145
212
357
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import misc class NormalizedFocalLossSigmoid(nn.Module): def __init__(self, axis=-1, alpha=0.25, gamma=2, from_logits=False, batch_axis=0, weight=None, size_average=True, detach_de...
47,691
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/metrics.py
86,87
1,102
_compute_iou
87,102
87,102
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
if ignore_mask is not None: pred_mask = torch.where(ignore_mask, torch.zeros_like(pred_mask), pred_mask) reduction_dims = misc.get_dims_with_exclusion(gt_mask.dim(), 0) union = torch.mean((pred_mask | gt_mask).float(), dim=reduction_dims).detach().cpu().numpy() intersection = torch.mean((pred_m...
if ignore_mask is not None: pred_mask = torch.where(ignore_mask, torch.zeros_like(pred_mask), pred_mask) reduction_dims = misc.get_dims_with_exclusion(gt_mask.dim(), 0) union = torch.mean((pred_mask | gt_mask).float(), dim=reduction_dims).detach().cpu().numpy() intersection = torch.mean((pred_m...
51
1,053
232
1,285
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
47,692
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/metrics.py
44,45
29,86
update
AdaptiveIoU
45,67
45,67
class AdaptiveIoU(TrainMetric): def __init__(self, init_thresh=0.4, thresh_step=0.025, thresh_beta=0.99, iou_beta=0.9, ignore_label=-1, from_logits=True, pred_output='instances', gt_output='instances'): super().__init__(pred_outputs=(pred_output,), gt_outputs=(gt_output,)) ...
class AdaptiveIoU(TrainMetric): def __init__(self, init_thresh=0.4, thresh_step=0.025, thresh_beta=0.99, iou_beta=0.9, ignore_label=-1, from_logits=True, pred_output='instances', gt_output='instances'): super().__init__(pred_outputs=(pred_output,), gt_outputs=(gt_output,)) ...
gt_mask = gt > 0 if self._from_logits: pred = torch.sigmoid(pred) gt_mask_area = torch.sum(gt_mask, dim=(1, 2)).detach().cpu().numpy() if np.all(gt_mask_area == 0): return ignore_mask = gt == self._ignore_label max_iou = _compute_iou(pred > self....
gt_mask = gt > 0 if self._from_logits: pred = torch.sigmoid(pred) gt_mask_area = torch.sum(gt_mask, dim=(1, 2)).detach().cpu().numpy() if np.all(gt_mask_area == 0): return ignore_mask = gt == self._ignore_label max_iou = _compute_iou(pred > self....
89
490
371
861
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
47,693
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/metrics.py
18,19
7,29
reset_epoch_stats
TrainMetric
19,21
19,21
class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self): raise NotImplementedError def reset_epoch_stat...
class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self): raise NotImplementedError def reset_epoch_stat...
raise NotImplementedError
raise NotImplementedError
2
166
11
177
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
import torch import numpy as np from ..utils import misc class TrainMetric(object): def __init__(self, pred_outputs, gt_outputs): self.pred_outputs = pred_outputs self.gt_outputs = gt_outputs def update(self, *args, **kwargs): raise NotImplementedError def get_epoch_value(self):...
47,694
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/basic_blocks.py
23,24
6,27
forward
ConvHead
24,27
24,27
class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(num_layers): convhead.extend([ ...
class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(num_layers): convhead.extend([ ...
return self.convhead(inputs[0])
return self.convhead(inputs[0])
2
237
18
255
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
47,695
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/basic_blocks.py
51,52
27,57
forward
SepConvHead
52,57
52,57
class SepConvHead(nn.Module): def __init__(self, num_outputs, in_channels, mid_channels, num_layers=1, kernel_size=3, padding=1, dropout_ratio=0.0, dropout_indx=0, norm_layer=nn.BatchNorm2d): super(SepConvHead, self).__init__() sepconvhead = [] for i in ra...
class SepConvHead(nn.Module): def __init__(self, num_outputs, in_channels, mid_channels, num_layers=1, kernel_size=3, padding=1, dropout_ratio=0.0, dropout_indx=0, norm_layer=nn.BatchNorm2d): super(SepConvHead, self).__init__() sepconvhead = [] for i in ra...
x = inputs[0] return self.layers(x)
x = inputs[0] return self.layers(x)
5
329
25
354
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
47,696
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/basic_blocks.py
70,71
57,72
forward
SeparableConv2d
71,72
71,72
class SeparableConv2d(nn.Module): def __init__(self, in_channels, out_channels, dw_kernel, dw_padding, dw_stride=1, activation=None, use_bias=False, norm_layer=None): super(SeparableConv2d, self).__init__() _activation = ops.select_activation_function(activation) self.body =...
class SeparableConv2d(nn.Module): def __init__(self, in_channels, out_channels, dw_kernel, dw_padding, dw_stride=1, activation=None, use_bias=False, norm_layer=None): super(SeparableConv2d, self).__init__() _activation = ops.select_activation_function(activation) self.body =...
return self.body(x)
return self.body(x)
2
267
10
277
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
import torch.nn as nn from ...model import ops class ConvHead(nn.Module): def __init__(self, out_channels, in_channels=32, num_layers=1, kernel_size=3, padding=1, norm_layer=nn.BatchNorm2d): super(ConvHead, self).__init__() convhead = [] for i in range(n...
47,698
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/deeplab_v3.py
51,52
12,84
load_pretrained_weights
DeepLabV3Plus
52,64
52,64
class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ch=256, project_dropout=0.5, inference_mode=False, **kwargs): super(DeepLabV3Plus, self).__init__(...
class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, backbone_norm_layer=None, ch=256, project_dropout=0.5, inference_mode=False, **kwargs): super(DeepLabV3Plus, self).__init__(...
pretrained = ResNetBackbone(backbone=self.backbone_name, pretrained_base=True, norm_layer=self.backbone_norm_layer, **self._kwargs) backbone_state_dict = self.backbone.state_dict() pretrained_state_dict = pretrained.state_dict() backbone_state_dict.up...
pretrained = ResNetBackbone(backbone=self.backbone_name, pretrained_base=True, norm_layer=self.backbone_norm_layer, **self._kwargs) backbone_state_dict = self.backbone.state_dict() pretrained_state_dict = pretrained.state_dict() backbone_state_dict.up...
23
721
166
887
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
47,699
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/deeplab_v3.py
144,145
115,150
forward
_ASPP
145,150
145,150
class _ASPP(nn.Module): def __init__(self, in_channels, atrous_rates, out_channels=256, project_dropout=0.5, norm_layer=nn.BatchNorm2d): super(_ASPP, self).__init__() b0 = nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=1, bias=F...
class _ASPP(nn.Module): def __init__(self, in_channels, atrous_rates, out_channels=256, project_dropout=0.5, norm_layer=nn.BatchNorm2d): super(_ASPP, self).__init__() b0 = nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=1, bias=F...
x = torch.cat([block(x) for block in self.concurent], dim=1) return self.project(x)
x = torch.cat([block(x) for block in self.concurent], dim=1) return self.project(x)
10
445
43
488
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
47,700
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/deeplab_v3.py
162,163
150,167
forward
_AsppPooling
163,167
163,167
class _AsppPooling(nn.Module): def __init__(self, in_channels, out_channels, norm_layer): super(_AsppPooling, self).__init__() self.gap = nn.Sequential( nn.AdaptiveAvgPool2d((1, 1)), nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_s...
class _AsppPooling(nn.Module): def __init__(self, in_channels, out_channels, norm_layer): super(_AsppPooling, self).__init__() self.gap = nn.Sequential( nn.AdaptiveAvgPool2d((1, 1)), nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_s...
pool = self.gap(x) return F.interpolate(pool, x.size()[2:], mode='bilinear', align_corners=True)
pool = self.gap(x) return F.interpolate(pool, x.size()[2:], mode='bilinear', align_corners=True)
8
169
50
219
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
47,701
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/deeplab_v3.py
111,112
99,115
forward
_DeepLabHead
112,115
112,115
class _DeepLabHead(nn.Module): def __init__(self, out_channels, in_channels, mid_channels=256, norm_layer=nn.BatchNorm2d): super(_DeepLabHead, self).__init__() self.block = nn.Sequential( SeparableConv2d(in_channels=in_channels, out_channels=mid_channels, dw_kernel=3, ...
class _DeepLabHead(nn.Module): def __init__(self, out_channels, in_channels, mid_channels=256, norm_layer=nn.BatchNorm2d): super(_DeepLabHead, self).__init__() self.block = nn.Sequential( SeparableConv2d(in_channels=in_channels, out_channels=mid_channels, dw_kernel=3, ...
return self.block(x)
return self.block(x)
2
254
14
268
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
47,702
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/deeplab_v3.py
95,96
84,99
forward
_SkipProject
96,99
96,99
class _SkipProject(nn.Module): def __init__(self, in_channels, out_channels, norm_layer=nn.BatchNorm2d): super(_SkipProject, self).__init__() _activation = ops.select_activation_function("relu") self.skip_project = nn.Sequential( nn.Conv2d(in_channels, out_channels, kernel_size=...
class _SkipProject(nn.Module): def __init__(self, in_channels, out_channels, norm_layer=nn.BatchNorm2d): super(_SkipProject, self).__init__() _activation = ops.select_activation_function("relu") self.skip_project = nn.Sequential( nn.Conv2d(in_channels, out_channels, kernel_size=...
return self.skip_project(x)
return self.skip_project(x)
2
157
16
173
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
from contextlib import ExitStack import torch from torch import nn import torch.nn.functional as F from .basic_blocks import SeparableConv2d from .resnet import ResNetBackbone from ...model import ops class DeepLabV3Plus(nn.Module): def __init__(self, backbone='resnet50', norm_layer=nn.BatchNorm2d, ...
47,703
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/hrnet_ocr.py
83,84
13,155
_make_fuse_layers
HighResolutionModule
84,125
84,125
class HighResolutionModule(nn.Module): def __init__(self, num_branches, blocks, num_blocks, num_inchannels, num_channels, fuse_method,multi_scale_output=True, norm_layer=nn.BatchNorm2d, align_corners=True): super(HighResolutionModule, self).__init__() self._check_br...
class HighResolutionModule(nn.Module): def __init__(self, num_branches, blocks, num_blocks, num_inchannels, num_channels, fuse_method,multi_scale_output=True, norm_layer=nn.BatchNorm2d, align_corners=True): super(HighResolutionModule, self).__init__() self._check_br...
if self.num_branches == 1: return None num_branches = self.num_branches num_inchannels = self.num_inchannels fuse_layers = [] for i in range(num_branches if self.multi_scale_output else 1): fuse_layer = [] for j in range(num_branches): ...
if self.num_branches == 1: return None num_branches = self.num_branches num_inchannels = self.num_inchannels fuse_layers = [] for i in range(num_branches if self.multi_scale_output else 1): fuse_layer = [] for j in range(num_branches): ...
91
1,313
566
1,879
import os import numpy as np import torch import torch.nn as nn import torch._utils import torch.nn.functional as F from .ocr import SpatialOCR_Module, SpatialGather_Module from .resnetv1b import BasicBlockV1b, BottleneckV1b relu_inplace = True class HighResolutionModule(nn.Module): def __init__(self, num_branch...
import os import numpy as np import torch import torch.nn as nn import torch._utils import torch.nn.functional as F from .ocr import SpatialOCR_Module, SpatialGather_Module from .resnetv1b import BasicBlockV1b, BottleneckV1b relu_inplace = True class HighResolutionModule(nn.Module): def __init__(self, num_branch...
47,705
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/ocr.py
117,118
63,142
forward
ObjectAttentionBlock2D
118,142
118,142
class ObjectAttentionBlock2D(nn.Module): ''' The basic implementation for object context block Input: N X C X H X W Parameters: in_channels : the dimension of the input feature map key_channels : the dimension after the key/query transform scale : c...
class ObjectAttentionBlock2D(nn.Module): ''' The basic implementation for object context block Input: N X C X H X W Parameters: in_channels : the dimension of the input feature map key_channels : the dimension after the key/query transform scale : c...
batch_size, h, w = x.size(0), x.size(2), x.size(3) if self.scale > 1: x = self.pool(x) query = self.f_pixel(x).view(batch_size, self.key_channels, -1) query = query.permute(0, 2, 1) key = self.f_object(proxy).view(batch_size, self.key_channels, -1) value = se...
batch_size, h, w = x.size(0), x.size(2), x.size(3) if self.scale > 1: x = self.pool(x) query = self.f_pixel(x).view(batch_size, self.key_channels, -1) query = query.permute(0, 2, 1) key = self.f_object(proxy).view(batch_size, self.key_channels, -1) value = se...
89
878
397
1,275
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
47,706
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/ocr.py
19,20
7,30
forward
SpatialGather_Module
20,30
20,30
class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ def __init__(self, cls_num=0, scale=1): super(SpatialGather_Module, self).__in...
class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ def __init__(self, cls_num=0, scale=1): super(SpatialGather_Module, self).__in...
batch_size, c, h, w = probs.size(0), probs.size(1), probs.size(2), probs.size(3) probs = probs.view(batch_size, c, -1) feats = feats.view(batch_size, feats.size(1), -1) feats = feats.permute(0, 2, 1) # batch x hw x c probs = F.softmax(self.scale * probs, dim=2) # batch x k x hw...
batch_size, c, h, w = probs.size(0), probs.size(1), probs.size(2), probs.size(3) probs = probs.view(batch_size, c, -1) feats = feats.view(batch_size, feats.size(1), -1) feats = feats.permute(0, 2, 1) # batch x hw x c probs = F.softmax(self.scale * probs, dim=2) # batch x k x hw...
58
132
209
341
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
47,707
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/ocr.py
55,56
30,63
forward
SpatialOCR_Module
56,63
56,63
class SpatialOCR_Module(nn.Module): """ Implementation of the OCR module: We aggregate the global object representation to update the representation for each pixel. """ def __init__(self, in_channels, key_channels, out_channels, sc...
class SpatialOCR_Module(nn.Module): """ Implementation of the OCR module: We aggregate the global object representation to update the representation for each pixel. """ def __init__(self, in_channels, key_channels, out_channels, sc...
context = self.object_context_block(feats, proxy_feats) output = self.conv_bn_dropout(torch.cat([context, feats], 1)) return output
context = self.object_context_block(feats, proxy_feats) output = self.conv_bn_dropout(torch.cat([context, feats], 1)) return output
11
310
61
371
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
import torch import torch.nn as nn import torch._utils import torch.nn.functional as F class SpatialGather_Module(nn.Module): """ Aggregate the context features according to the initial predicted probability distribution. Employ the soft-weighted method to aggregate the context. """ ...
47,708
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/resnet.py
29,30
5,40
forward
ResNetBackbone
30,40
30,40
class ResNetBackbone(torch.nn.Module): def __init__(self, backbone='resnet50', pretrained_base=True, dilated=True, **kwargs): super(ResNetBackbone, self).__init__() if backbone == 'resnet34': pretrained = resnet34_v1b(pretrained=pretrained_base, dilated=dilated, **kwargs) elif b...
class ResNetBackbone(torch.nn.Module): def __init__(self, backbone='resnet50', pretrained_base=True, dilated=True, **kwargs): super(ResNetBackbone, self).__init__() if backbone == 'resnet34': pretrained = resnet34_v1b(pretrained=pretrained_base, dilated=dilated, **kwargs) elif b...
x = self.conv1(x) x = self.bn1(x) x = self.relu(x) x = self.maxpool(x) c1 = self.layer1(x) c2 = self.layer2(c1) c3 = self.layer3(c2) c4 = self.layer4(c3) return c1, c2, c3, c4
x = self.conv1(x) x = self.bn1(x) x = self.relu(x) x = self.maxpool(x) c1 = self.layer1(x) c2 = self.layer2(c1) c3 = self.layer3(c2) c4 = self.layer4(c3) return c1, c2, c3, c4
29
380
120
500
import torch from .resnetv1b import resnet34_v1b, resnet50_v1s, resnet101_v1s, resnet152_v1s class ResNetBackbone(torch.nn.Module): def __init__(self, backbone='resnet50', pretrained_base=True, dilated=True, **kwargs): super(ResNetBackbone, self).__init__() if backbone == 'resnet34': ...
import torch from .resnetv1b import resnet34_v1b, resnet50_v1s, resnet101_v1s, resnet152_v1s class ResNetBackbone(torch.nn.Module): def __init__(self, backbone='resnet50', pretrained_base=True, dilated=True, **kwargs): super(ResNetBackbone, self).__init__() if backbone == 'resnet34': ...
47,710
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/resnetv1b.py
23,24
6,42
forward
BasicBlockV1b
24,42
24,42
class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(BasicBlockV1b, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=3, stride=stride...
class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(BasicBlockV1b, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=3, stride=stride...
residual = x out = self.conv1(x) out = self.bn1(out) out = self.relu(out) out = self.conv2(out) out = self.bn2(out) if self.downsample is not None: residual = self.downsample(x) out = out + residual out = self.relu(out) ret...
residual = x out = self.conv1(x) out = self.bn1(out) out = self.relu(out) out = self.conv2(out) out = self.bn2(out) if self.downsample is not None: residual = self.downsample(x) out = out + residual out = self.relu(out) ret...
36
271
129
400
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
47,711
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/resnetv1b.py
62,63
42,85
forward
BottleneckV1b
63,85
63,85
class BottleneckV1b(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(BottleneckV1b, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False) ...
class BottleneckV1b(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(BottleneckV1b, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False) ...
residual = x out = self.conv1(x) out = self.bn1(out) out = self.relu(out) out = self.conv2(out) out = self.bn2(out) out = self.relu(out) out = self.conv3(out) out = self.bn3(out) if self.downsample is not None: residual = se...
residual = x out = self.conv1(x) out = self.bn1(out) out = self.relu(out) out = self.conv2(out) out = self.bn2(out) out = self.relu(out) out = self.conv3(out) out = self.bn3(out) if self.downsample is not None: residual = se...
45
311
167
478
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
47,712
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/modeling/resnetv1b.py
153,155
85,217
_make_layer
ResNetV1b
155,197
155,197
class ResNetV1b(nn.Module): """ Pre-trained ResNetV1b Model, which produces the strides of 8 featuremaps at conv5. Parameters ---------- block : Block Class for the residual block. Options are BasicBlockV1, BottleneckV1. layers : list of int Numbers of layers in each block class...
class ResNetV1b(nn.Module): """ Pre-trained ResNetV1b Model, which produces the strides of 8 featuremaps at conv5. Parameters ---------- block : Block Class for the residual block. Options are BasicBlockV1, BottleneckV1. layers : list of int Numbers of layers in each block class...
downsample = None if stride != 1 or self.inplanes != planes * block.expansion: downsample = [] if avg_down: if dilation == 1: downsample.append( nn.AvgPool2d(kernel_size=stride, stride=stride, ceil_mode=True, count_inclu...
downsample = None if stride != 1 or self.inplanes != planes * block.expansion: downsample = [] if avg_down: if dilation == 1: downsample.append( nn.AvgPool2d(kernel_size=stride, stride=stride, ceil_mode=True, count_inclu...
115
1,357
584
1,941
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
import torch import torch.nn as nn GLUON_RESNET_TORCH_HUB = 'rwightman/pytorch-pretrained-gluonresnet' class BasicBlockV1b(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, previous_dilation=1, norm_layer=nn.BatchNorm2d): super(Basi...
47,713
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/ops.py
9,10
1,84
select_activation_function
10,23
10,23
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): FILL_FUNC_BODYclass BilinearConvTranspose2d(nn.ConvTranspose2d): def __init__(self, in_channels, out_channels, scale, groups=1):...
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): FILL_FUNC_BODYclass BilinearConvTranspose2d(nn.ConvTranspose2d): def __init__(self, in_channels, out_channels, scale, groups=1):...
if isinstance(activation, str): if activation.lower() == 'relu': return nn.ReLU elif activation.lower() == 'softplus': return nn.Softplus else: raise ValueError(f"Unknown activation type {activation}") elif isinstance(activation, nn.Module): re...
if isinstance(activation, str): if activation.lower() == 'relu': return nn.ReLU elif activation.lower() == 'softplus': return nn.Softplus else: raise ValueError(f"Unknown activation type {activation}") elif isinstance(activation, nn.Module): re...
32
944
125
1,069
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): FILL_FUNC_BODYclass BilinearConvTranspose2d(nn.ConvTranspose2d): def __init__(self, in_channels, out_channels, scale, groups=1):...
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): FILL_FUNC_BODYclass BilinearConvTranspose2d(nn.ConvTranspose2d): def __init__(self, in_channels, out_channels, scale, groups=1):...
47,714
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/ops.py
46,47
39,84
get_coord_features
DistMaps
47,82
47,82
class DistMaps(nn.Module): def __init__(self, norm_radius, spatial_scale=1.0, cpu_mode=False): super(DistMaps, self).__init__() self.spatial_scale = spatial_scale self.norm_radius = norm_radius self.cpu_mode = cpu_mode def get_coord_features(self, points, batchsize, rows, cols):...
class DistMaps(nn.Module): def __init__(self, norm_radius, spatial_scale=1.0, cpu_mode=False): super(DistMaps, self).__init__() self.spatial_scale = spatial_scale self.norm_radius = norm_radius self.cpu_mode = cpu_mode def get_coord_features(self, points, batchsize, rows, cols):...
if self.cpu_mode: coords = [] for i in range(batchsize): norm_delimeter = self.spatial_scale * self.norm_radius coords.append(get_dist_maps(points[i].cpu().float().numpy(), rows, cols, norm_delimeter)) ...
if self.cpu_mode: coords = [] for i in range(batchsize): norm_delimeter = self.spatial_scale * self.norm_radius coords.append(get_dist_maps(points[i].cpu().float().numpy(), rows, cols, norm_delimeter)) ...
126
164
601
765
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): if isinstance(activation, str): if activation.lower() == 'relu': return nn.ReLU elif activation.lowe...
import torch from torch import nn as nn import numpy as np from . import initializer as initializer from ..utils.cython import get_dist_maps def select_activation_function(activation): if isinstance(activation, str): if activation.lower() == 'relu': return nn.ReLU elif activation.lowe...
47,715
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/model/syncbn/modules/functional/_csrc.py
27,28
1,55
_load_C_extensions
28,54
28,54
""" /*****************************************************************************/ Extension module loader code referenced from : https://github.com/facebookresearch/maskrcnn-benchmark /*****************************************************************************/ """ from __future__ import absolute_import from __f...
""" /*****************************************************************************/ Extension module loader code referenced from : https://github.com/facebookresearch/maskrcnn-benchmark /*****************************************************************************/ """ from __future__ import absolute_import from __f...
this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) sources_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) sources_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) sources = main...
this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) sources_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) sources_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) sources = main...
66
179
360
539
""" /*****************************************************************************/ Extension module loader code referenced from : https://github.com/facebookresearch/maskrcnn-benchmark /*****************************************************************************/ """ from __future__ import absolute_import from __f...
""" /*****************************************************************************/ Extension module loader code referenced from : https://github.com/facebookresearch/maskrcnn-benchmark /*****************************************************************************/ """ from __future__ import absolute_import from __f...
47,716
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/utils/cython/_get_dist_maps.pyxbld
3,4
1,8
make_ext
4,8
4,8
import numpy def make_ext(modname, pyxfilename): FILL_FUNC_BODY
import numpy def make_ext(modname, pyxfilename): FILL_FUNC_BODY
from distutils.extension import Extension return Extension(modname, [pyxfilename], include_dirs=[numpy.get_include()], extra_compile_args=['-O3'], language='c++')
from distutils.extension import Extension return Extension(modname, [pyxfilename], include_dirs=[numpy.get_include()], extra_compile_args=['-O3'], language='c++')
10
28
62
90
import numpy def make_ext(modname, pyxfilename): FILL_FUNC_BODY
import numpy def make_ext(modname, pyxfilename): FILL_FUNC_BODY
47,717
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs/utils/misc.py
15,16
1,63
get_unique_labels
16,19
16,19
from functools import partial import torch import numpy as np def get_dims_with_exclusion(dim, exclude=None): dims = list(range(dim)) if exclude is not None: dims.remove(exclude) return dims def get_unique_labels(mask): FILL_FUNC_BODYdef get_bbox_from_mask(mask): rows = np.any(mask, axis=1...
from functools import partial import torch import numpy as np def get_dims_with_exclusion(dim, exclude=None): dims = list(range(dim)) if exclude is not None: dims.remove(exclude) return dims def get_unique_labels(mask): FILL_FUNC_BODYdef get_bbox_from_mask(mask): rows = np.any(mask, axis=1...
return np.nonzero(np.bincount(mask.flatten() + 1))[0] - 1
return np.nonzero(np.bincount(mask.flatten() + 1))[0] - 1
6
686
33
719
from functools import partial import torch import numpy as np def get_dims_with_exclusion(dim, exclude=None): dims = list(range(dim)) if exclude is not None: dims.remove(exclude) return dims def get_unique_labels(mask): FILL_FUNC_BODYdef get_bbox_from_mask(mask): rows = np.any(mask, axis=1...
from functools import partial import torch import numpy as np def get_dims_with_exclusion(dim, exclude=None): dims = list(range(dim)) if exclude is not None: dims.remove(exclude) return dims def get_unique_labels(mask): FILL_FUNC_BODYdef get_bbox_from_mask(mask): rows = np.any(mask, axis=1...
47,718
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem
/home/hieuvd/dung_repo/raw/stars_03/hkchengrex_XMem/XMem/inference/interact/fbrs_controller.py
48,49
6,54
undo
FBRSController
49,54
49,54
class FBRSController: def __init__(self, checkpoint_path, device='cuda:0', max_size=800): model = utils.load_is_model(checkpoint_path, device, cpu_dist_maps=True, norm_radius=260) # Predictor params zoomin_params = { 'skip_clicks': 1, 'target_size': 480, ...
class FBRSController: def __init__(self, checkpoint_path, device='cuda:0', max_size=800): model = utils.load_is_model(checkpoint_path, device, cpu_dist_maps=True, norm_radius=260) # Predictor params zoomin_params = { 'skip_clicks': 1, 'target_size': 480, ...
self.controller.undo_click() if len(self.controller.probs_history) == 0: return None else: return (self.controller.probs_history[-1][1]>0.5).float()
self.controller.undo_click() if len(self.controller.probs_history) == 0: return None else: return (self.controller.probs_history[-1][1]>0.5).float()
10
484
63
547
import torch from .fbrs.controller import InteractiveController from .fbrs.inference import utils class FBRSController: def __init__(self, checkpoint_path, device='cuda:0', max_size=800): model = utils.load_is_model(checkpoint_path, device, cpu_dist_maps=True, norm_radius=260) # Predictor params ...
import torch from .fbrs.controller import InteractiveController from .fbrs.inference import utils class FBRSController: def __init__(self, checkpoint_path, device='cuda:0', max_size=800): model = utils.load_is_model(checkpoint_path, device, cpu_dist_maps=True, norm_radius=260) # Predictor params ...