'VS2022 - Git Changes with submodule always shows change
I have a large solution (CoreServices) that utilizes a common library (Common). I have another large solution that also utilizes the common library so submodules seemed like the right answer. Most of the time, they are.
VS2022 is supposed to have support for these submodules. However, in my Git Changes window, it ALWAYS says I have a modified submodule reference - and it doesn't matter what branch I'm on. I can't stage the change...or undo it. Trying to commit tells me there are no files. I've thought maybe I'll just find wherever the commit hash is living on the superproject and update it but to no avail.
Can anyone explain this behavior?
Solution 1:[1]
For anyone looking at this.
There seems to be some different cases where this might happen. For me the submodule was stuck in a modified state and doing git restore modulename or git checkout modulename or any variations on git submodule update did nothing.
Resetting the submodule worked for me:
git submodule foreach --recursive git reset --hard
Alternatively if that breaks you can try:
git submodule deinit -f .
# Initialize again
git submodule update --init --recursive
Solution 2:[2]
You can use augmentation to generate those 200 missing images. For example, rotate the first 200 images by 90°. implemented in this code.
import os
import cv2
path_to_folder = "path_to_your_class_B_folder"
list_items_in_dir = os.listdir(path_to_folder)
for index, item in enumerate(list_items_in_dir):
if index >= 200:
break
img = cv2.imread(path_to_folder+"/"+item)
cv2.rotate(img, 90)
cv2.imwrite(path_to_folder+"/"+item, img)
For that, you will need cv2 which can be installed by using this cmd
pip install opencv-python
You can also randomize the angle of rotation:
import os
import cv2
import random
path_to_folder = "path_to_your_class_B_folder"
list_items_in_dir = os.listdir(path_to_folder)
for index, item in enumerate(list_items_in_dir):
if index >= 200:
break
img = cv2.imread(path_to_folder+"/"+item)
cv2.rotate(img, random.randint)
cv2.imwrite(path_to_folder+"/"+item, img)
If you want to use Tensorflow itself it is capable too to augment your data
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Esben Bach |
| Solution 2 |

