Skip to content

Commit

Permalink
loading large_tile
Browse files Browse the repository at this point in the history
  • Loading branch information
AAA11110 committed Dec 4, 2023
1 parent 9ac93af commit d74164d
Show file tree
Hide file tree
Showing 517 changed files with 389 additions and 121 deletions.
Binary file removed Augmentation/__pycache__/transform.cpython-310.pyc
Binary file not shown.
120 changes: 60 additions & 60 deletions ToBeChecked/Demo_SAMGhandour.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/geoaigroup/geotils/blob/main/ToBeChecked/Demo_SAMGhandour.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
Expand Down Expand Up @@ -39,41 +39,41 @@
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"execution_count": null,
"metadata": {
"id": "z3MWlXeRqbHM"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "CJdWU3inqwLB"
},
"outputs": [],
"source": [
"!pip install rasterio\n",
"!git clone https://github.com/facebookresearch/segment-anything\n",
"%cd /content/segment-anything\n",
"!pip install -e .\n",
"%cd ..\n"
],
"metadata": {
"id": "CJdWU3inqwLB"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"source": [
"!wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth"
],
"execution_count": null,
"metadata": {
"id": "mpD6G0w6tvp7"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"!wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth"
]
},
{
"cell_type": "code",
Expand Down Expand Up @@ -404,21 +404,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "FMflz7K4yFT7"
},
"outputs": [],
"source": [
"h,w = full_mask.shape[:2]\n",
"t,b,l,r = rrp_info['pads']\n",
"orig_size = rrp_info['orig_size']\n",
"\n",
"full_mask = full_mask[t:h-b,l:w-r]"
],
"metadata": {
"id": "FMflz7K4yFT7"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "z45_wF_wy1if"
},
"outputs": [],
"source": [
"shapes = rasterio.features.shapes(full_mask, mask=None, transform=raster_file.transform)\n",
"# read the shapes as separate lists\n",
Expand All @@ -434,12 +439,7 @@
"\n",
"#gdf = gdf.dissolve(by='id')\n",
"full_gdf.to_file(f'{out_dir}/{filename}')"
],
"metadata": {
"id": "z45_wF_wy1if"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
Expand Down Expand Up @@ -487,6 +487,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "EX8ErmOJ7sNd"
},
"outputs": [],
"source": [
"import torch\n",
"import argparse\n",
Expand All @@ -510,15 +515,15 @@
"from rasterio.features import shapes\n",
"from tqdm.notebook import tqdm\n",
"from models.Unet_W_Mods import UnetWM"
],
"metadata": {
"id": "EX8ErmOJ7sNd"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4OBEWHB_7LrZ"
},
"outputs": [],
"source": [
"#use Lebanese Model or WHU model\n",
"MODEL_PATH = '/content/drive/MyDrive/LargeFilesSharing'\n",
Expand Down Expand Up @@ -627,15 +632,15 @@
" gdf = gpd.GeoDataFrame.from_features(list(results),crs=raster_file.crs)\n",
" gdf = gdf.dissolve(by='id')\n",
" gdf.to_file(f'{out_dir}/{filename}')"
],
"metadata": {
"id": "4OBEWHB_7LrZ"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "JmVlDNUDxOGJ"
},
"outputs": [],
"source": [
"#to Geotifff\n",
"out_path = '/content/results'\n",
Expand All @@ -653,41 +658,36 @@
" transform=raster_file.transform) as f:\n",
"\n",
" f.write(instances[np.newaxis,:,:].astype(np.uint16))\n"
],
"metadata": {
"id": "JmVlDNUDxOGJ"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"source": [
"!ls -la /content/results"
],
"execution_count": null,
"metadata": {
"id": "w45X9-Ly7ntK"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"!ls -la /content/results"
]
},
{
"cell_type": "code",
"source": [],
"execution_count": null,
"metadata": {
"id": "pUeUVkbCxaPe"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": []
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"gpuType": "T4",
"include_colab_link": true,
"machine_shape": "hm",
"provenance": [],
"include_colab_link": true
"provenance": []
},
"kernelspec": {
"display_name": "urbanmodels_venv",
Expand All @@ -709,4 +709,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
2 changes: 1 addition & 1 deletion ToBeChecked/Demo_SAMMayladan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
" input_boxes=[]\n",
" flag=1\n",
" ##for georeferenced polygons\n",
" mask=utils.convert_polygon_to_mask_batch_transform(geo,(1024,1024),transform=transform)\n",
" mask=utils.convert_polygon_to_mask_batch(geo,(1024,1024),transform=transform)\n",
" tile_boxes=utils.create_boxes(mask,shapefile=False)\n",
" \n",
" # tile_boxes=utils.create_boxes(geo,shapefile=False)\n",
Expand Down
Binary file removed data/images/2_31.png
Binary file not shown.
Binary file added data/images/n1.tif
Binary file not shown.
1 change: 1 addition & 0 deletions data/n1/n1.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ISO-8859-1
Binary file added data/n1/n1.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions data/n1/n1.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["WGS_1984_UTM_Zone_14N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-99.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Loading

0 comments on commit d74164d

Please sign in to comment.