
import numpy as np

from scripts import get_id_convert_dicts
print('yes')
def get_unseen_index(zero_shot_type):
    unseen_idx = None
    if zero_shot_type == 1:
        from ult.config import cfg
        num_inst_path = cfg.LOCAL_DATA + '/num_inst.npy'
        num_inst = np.load(num_inst_path)
        unseen_idx = np.where(num_inst <= 10)[0]
    elif zero_shot_type == 2:
        unseen_idx = [516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 538, 539, 540, 541, 542, 543, 544,
                      545, 546, 547, 548, 549, 558, 559, 560, 561, 576, 577, 578, 579, 580, 581, 582, 583, 76, 77, 78,
                      79, 80, 81, 82, 83, 84, 85, 107, 108, 109, 110, 194, 195, 196, 197, 208, 209, 210, 211, 212, 213,
                      235, 236, 237, 238, 239, 240, 241, 242, 325, 326, 327, 328, 329, 342, 343, 344, 345, 346, 347,
                      376, 377, 378, 379, 380, 381, 382, 393, 394, 395, 396, 414, 415, 416, 417, 429, 430, 431, 432,
                      433, 434, 435, 436, 437, 449, 450, 451, 452, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473]
    elif zero_shot_type == 8:
        unseen_idx = [366, 143, 314, 115, 459, 415, 313, 387, 117, 131, 457, 241, 455, 226, 156, 271, 264, 577, 518, 385, 266, 347, 78, 476, 479]
    elif zero_shot_type == 9:
        unseen_idx = [366, 143, 314, 115, 459, 415, 313, 387, 117, 131, 457, 241, 455, 226, 156, 271, 264, 577, 518, 385, 266, 347, 78, 476, 479]


    elif zero_shot_type == 11:
        unseen_idx = [111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
                      126, 127, 128, 224, 225, 226, 227, 228, 229, 230, 231, 290, 291, 292, 293,
                      294, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 336, 337,
                      338, 339, 340, 341, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428,
                      429, 430, 431, 432, 433, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462,
                      463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 533, 534, 535, 536,
                      537, 558, 559, 560, 561, 595, 596, 597, 598, 599]
        #  miss [ 5, 6, 28, 56, 88] verbs 006  break    007  brush_with 029  flip  057  move  089  slide
    elif zero_shot_type == 17:
        unseen_idx = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 24, 25, 26, 27, 28, 29, 30, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
         78, 79, 80, 81, 82, 83, 84, 85, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 170, 171, 172, 173, 186,
         187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 232,
         233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263,
         273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 290, 291, 292, 293, 294, 325, 326, 327, 328, 329, 330, 331,
         332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 348, 349, 350, 351, 352, 353, 354, 355, 389, 390, 391, 392,
         393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 434, 435, 436, 437, 483, 484, 485, 486,
         487, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522,
         523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 546, 547, 548, 549, 550, 551, 552,
         553, 554, 555, 556, 557, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 584, 585, 586,
         587, 595, 596, 597, 598, 599]
    elif zero_shot_type == 18:
        unseen_idx = [9, 23, 30, 45, 53, 64, 75, 85, 91, 95, 106, 110, 128, 145, 159, 169, 173, 185, 193, 197,
                      207, 213, 223, 231, 234, 238, 242, 246, 251, 256, 263, 272, 282, 289, 294, 304, 312, 324,
                      329, 335, 341, 347, 351, 355, 362, 367, 375, 382, 388, 392, 396, 406, 413, 417, 428, 433,
                      437, 444, 448, 452, 462, 473, 482, 487, 501, 505, 515, 527, 532, 537, 545, 549, 557, 561,
                      566, 575, 583, 587, 594, 599]
    elif zero_shot_type == 12:
        unseen_idx = [
           0, 1, 10, 29, 30, 41, 48, 50, 56, 57, 69, 72, 80, 81, 92, 93, 96, 109,
           110, 114, 127, 134, 139, 161, 170, 177, 183, 189, 191, 197, 198, 201,
           208, 209, 221, 227, 229, 232, 233, 235, 239, 242, 245, 247, 250, 252,
           260, 263, 270, 271, 280, 286, 288, 290, 299, 301, 308, 316, 325, 334,
           336, 343, 344, 352, 355, 356, 357, 363, 375, 376, 380, 384, 387, 389,
           395, 396, 397, 404, 408, 413, 414, 417, 422, 425, 433, 434, 436, 444,
           448, 452, 454, 455, 463, 480, 484, 488, 498, 503, 505, 507, 513, 516,
           527, 530, 532, 536, 537, 540, 546, 547, 550, 555, 561, 562, 566, 567,
           572, 581, 587, 598
       ]
    elif zero_shot_type == 13:
        unseen_idx = [
           0, 3, 22, 29, 32, 52, 58, 63, 72, 73, 78, 89, 91, 92, 105, 106, 107,
           113, 137, 148, 163, 165, 172, 178, 179, 194, 196, 207, 209, 210, 214,
           215, 229, 231, 233, 234, 236, 240, 241, 243, 245, 247, 252, 254, 260,
           262, 269, 272, 282, 286, 289, 292, 296, 302, 310, 315, 322, 326, 333,
           335, 338, 340, 343, 347, 350, 351, 353, 354, 358, 362, 367, 368, 376,
           380, 388, 389, 393, 395, 397, 399, 410, 412, 416, 417, 419, 420, 429,
           434, 439, 441, 445, 449, 454, 467, 476, 483, 495, 503, 507, 511, 519,
           528, 529, 535, 537, 539, 547, 548, 556, 557, 561, 563, 565, 569, 579,
           587, 589, 591, 595, 597
       ]
    elif zero_shot_type == 14:
        unseen_idx = [
           9, 25, 30, 49, 51, 61, 71, 74, 77, 82, 94, 108, 110, 116, 126, 131,
           143, 164, 168, 177, 185, 200, 201, 208, 212, 229, 232, 234, 239, 241,
           243, 244, 248, 255, 256, 258, 259, 266, 272, 279, 281, 287, 288, 290,
           294, 295, 301, 305, 308, 319, 322, 325, 328, 330, 332, 337, 344, 347,
           349, 350, 356, 359, 366, 367, 370, 375, 378, 380, 386, 387, 390, 391,
           400, 406, 409, 411, 416, 419, 428, 429, 431, 436, 439, 443, 445, 447,
           449, 451, 454, 457, 466, 468, 477, 479, 485, 486, 491, 497, 504, 508,
           510, 516, 527, 529, 531, 533, 536, 544, 545, 546, 549, 550, 552, 558,
           561, 568, 589, 594, 596, 599
       ]
    elif zero_shot_type == 15:
        unseen_idx = [
           4, 14, 26, 27, 41, 45, 51, 53, 62, 69, 74, 80, 88, 91, 92, 93, 100,
           107, 110, 125, 127, 130, 136, 152, 153, 163, 167, 170, 177, 183, 186,
           188, 196, 200, 207, 210, 217, 220, 225, 232, 237, 242, 243, 246, 248,
           252, 253, 263, 267, 270, 280, 285, 289, 291, 292, 302, 312, 316, 325,
           335, 341, 343, 348, 355, 356, 362, 363, 368, 378, 382, 384, 385, 390,
           394, 396, 404, 406, 407, 415, 416, 426, 428, 429, 431, 435, 441, 443,
           448, 450, 452, 454, 460, 467, 469, 479, 480, 483, 498, 503, 505, 509,
           518, 524, 532, 533, 541, 549, 551, 560, 561, 566, 572, 573, 579, 580,
           585, 587, 594, 595, 599
       ]
    elif zero_shot_type == 16:
        unseen_idx = [
           0, 4, 28, 29, 42, 43, 49, 53, 55, 56, 66, 72, 80, 81, 87, 90, 92, 94,
           100, 103, 109, 110, 129, 137, 149, 159, 166, 167, 170, 171, 179, 182,
           189, 193, 194, 195, 201, 206, 236, 237, 244, 245, 248, 249, 254, 255,
           257, 258, 266, 270, 290, 292, 300, 303, 316, 317, 326, 327, 331, 333,
           339, 340, 345, 347, 349, 350, 352, 353, 357, 362, 365, 366, 375, 380,
           381, 383, 385, 395, 396, 425, 426, 446, 448, 450, 451, 458, 466, 470,
           474, 476, 485, 487, 494, 495, 504, 505, 509, 515, 516, 525, 528, 529,
           536, 537, 539, 541, 546, 548, 556, 557, 568, 572, 578, 582, 585, 586,
           590, 593, 595, 597
       ]
    elif zero_shot_type == 3:
        # rare
        unseen_idx = [509, 279, 280, 402, 504, 286, 499, 498, 289, 485, 303, 311, 325, 439, 351, 358, 66, 427, 379, 418, 70, 416,
         389, 90, 395, 76, 397, 84, 135, 262, 401, 592, 560, 586, 548, 593, 526, 181, 257, 539, 535, 260, 596, 345, 189,
         205, 206, 429, 179, 350, 405, 522, 449, 261, 255, 546, 547, 44, 22, 334, 599, 239, 315, 317, 229, 158, 195,
         238, 364, 222, 281, 149, 399, 83, 127, 254, 398, 403, 555, 552, 520, 531, 440, 436, 482, 274, 8, 188, 216, 597,
         77, 407, 556, 469, 474, 107, 390, 410, 27, 381, 463, 99, 184, 100, 292, 517, 80, 333, 62, 354, 104, 55, 50,
         198, 168, 391, 192, 595, 136, 581]
    elif zero_shot_type == 4:
        # non rare
        unseen_idx = [38, 41, 20, 18, 245, 11, 19, 154, 459, 42, 155, 139, 60, 461, 577, 153, 582, 89, 141, 576, 75, 212, 472, 61,
         457, 146, 208, 94, 471, 131, 248, 544, 515, 566, 370, 481, 226, 250, 470, 323, 169, 480, 479, 230, 385, 73,
         159, 190, 377, 176, 249, 371, 284, 48, 583, 53, 162, 140, 185, 106, 294, 56, 320, 152, 374, 338, 29, 594, 346,
         456, 589, 45, 23, 67, 478, 223, 493, 228, 240, 215, 91, 115, 337, 559, 7, 218, 518, 297, 191, 266, 304, 6, 572,
         529, 312, 9, 308, 417, 197, 193, 163, 455, 25, 54, 575, 446, 387, 483, 534, 340, 508, 110, 329, 246, 173, 506,
         383, 93, 516, 64]
        # 25729, 93041
    elif zero_shot_type == 5:
        # 61 rare
        unseen_idx = [509, 402, 18, 286, 11, 498, 154, 485, 42, 311, 139, 439, 461, 358, 153, 66, 89, 379, 576, 70, 212, 389, 61,
         395, 146, 397, 94, 135, 131, 401, 544, 560, 370, 586, 226, 593, 470, 181, 169, 539, 479, 260, 385, 345, 159,
         205, 190, 429, 176, 350, 371, 522, 48, 112, 53, 255, 140, 547, 106, 549, 56, 334, 152, 239, 338, 317, 158, 346,
         238, 589, 222, 23, 149, 67, 83, 223, 254, 228, 403, 215, 552, 115, 531, 436, 7, 274, 518, 188, 191, 216, 266,
         77, 6, 529, 469, 9, 107, 417, 390, 193, 27, 455, 463, 25, 184, 575, 292, 387, 80, 483, 340, 354, 110, 55, 329,
         550, 246, 168, 383, 595]
    elif zero_shot_type == 6:
        # 24 rare
        unseen_idx = [371, 75, 532, 358, 419, 541, 195, 483, 277, 114, 210, 133, 373, 590, 85, 511, 128, 518, 579, 553, 394, 35, 547,
         14, 77, 64, 468, 132, 22, 301, 487, 544, 139, 576, 271, 258, 556, 444, 257, 162, 23, 407, 46, 259, 273, 104,
         593, 84, 473, 457, 32, 171, 583, 125, 329, 344, 79, 11, 307, 31, 283, 96, 545, 265, 19, 475, 460, 98, 448, 538,
         34, 151, 91, 582, 324, 370, 198, 93, 341, 393, 146, 26, 530, 390, 447, 51, 164, 474, 466, 218, 571, 107, 144,
         361, 326, 185, 50, 179, 517, 261, 202, 522, 256, 235, 355, 546, 103, 278, 392, 246, 254, 13, 596, 381, 21, 337,
         178, 318, 321, 193]
    elif zero_shot_type == 7:
        # 24 rare merge of zs3 & zs4
        unseen_idx = [509, 279, 280, 402, 504, 286, 499, 498, 289, 485, 303, 311, 325, 439, 351, 358, 66, 427, 379, 418, 70, 416, 389,
         90, 38, 41, 20, 18, 245, 11, 19, 154, 459, 42, 155, 139, 60, 461, 577, 153, 582, 89, 141, 576, 75, 212, 472, 61,
         457, 146, 208, 94, 471, 131, 248, 544, 515, 566, 370, 481, 226, 250, 470, 323, 169, 480, 479, 230, 385, 73, 159,
         190, 377, 176, 249, 371, 284, 48, 583, 53, 162, 140, 185, 106, 294, 56, 320, 152, 374, 338, 29, 594, 346, 456, 589,
         45, 23, 67, 478, 223, 493, 228, 240, 215, 91, 115, 337, 559, 7, 218, 518, 297, 191, 266, 304, 6, 572, 529, 312,
         9]
        # 22529, 14830, 22493, 17411, 21912,
    elif zero_shot_type == 0:
        unseen_idx = []
    return unseen_idx


print('yes')
import os
os.system('pwd')
inst = np.load('../../misc/num_inst.npy')
categories = []
zs_type = 3
unseen_hois = get_unseen_index(zs_type)

id_vb, id_obj, id_hoi, hoi_to_obj, hoi_to_verbs = get_id_convert_dicts()
num_obj = np.zeros([80])
num_verb = np.zeros([117])
print(len(unseen_hois))
for i in range(600):
    if i in unseen_hois:
        continue
    verb = hoi_to_verbs[i]
    obj = hoi_to_obj[i]
    num_verb[verb] += inst[i]
    num_obj[obj] += inst[i]

print(zs_type, np.sum(num_verb > 0), num_verb)
print(zs_type, np.sum(num_obj > 0), num_obj)