Spaces:
Runtime error
Runtime error
File size: 115,717 Bytes
1d000a7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 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 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: selenium in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (4.13.0)\n",
"Requirement already satisfied: urllib3<3,>=1.26 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (2.2.2)\n",
"Requirement already satisfied: trio~=0.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (0.22.2)\n",
"Requirement already satisfied: trio-websocket~=0.9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (0.11.1)\n",
"Requirement already satisfied: certifi>=2021.10.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (2023.5.7)\n",
"Requirement already satisfied: attrs>=20.1.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (23.1.0)\n",
"Requirement already satisfied: sortedcontainers in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (2.4.0)\n",
"Requirement already satisfied: idna in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (2.10)\n",
"Requirement already satisfied: outcome in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.2.0)\n",
"Requirement already satisfied: sniffio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.3.0)\n",
"Requirement already satisfied: cffi>=1.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.15.1)\n",
"Requirement already satisfied: exceptiongroup>=1.0.0rc9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.1.3)\n",
"Requirement already satisfied: wsproto>=0.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio-websocket~=0.9->selenium) (1.2.0)\n",
"Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (1.7.1)\n",
"Requirement already satisfied: pycparser in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from cffi>=1.14->trio~=0.17->selenium) (2.21)\n",
"Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.12.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: selenium in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (4.13.0)\n",
"Requirement already satisfied: chromedriver-autoinstaller in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (0.6.2)\n",
"Requirement already satisfied: urllib3<3,>=1.26 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (2.2.2)\n",
"Requirement already satisfied: trio~=0.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (0.22.2)\n",
"Requirement already satisfied: trio-websocket~=0.9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (0.11.1)\n",
"Requirement already satisfied: certifi>=2021.10.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium) (2023.5.7)\n",
"Requirement already satisfied: attrs>=20.1.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (23.1.0)\n",
"Requirement already satisfied: sortedcontainers in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (2.4.0)\n",
"Requirement already satisfied: idna in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (2.10)\n",
"Requirement already satisfied: outcome in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.2.0)\n",
"Requirement already satisfied: sniffio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.3.0)\n",
"Requirement already satisfied: cffi>=1.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.15.1)\n",
"Requirement already satisfied: exceptiongroup>=1.0.0rc9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium) (1.1.3)\n",
"Requirement already satisfied: wsproto>=0.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio-websocket~=0.9->selenium) (1.2.0)\n",
"Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (1.7.1)\n",
"Requirement already satisfied: pycparser in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from cffi>=1.14->trio~=0.17->selenium) (2.21)\n",
"Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.12.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: webdriver-manager in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (4.0.1)\n",
"Requirement already satisfied: requests in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from webdriver-manager) (2.32.3)\n",
"Requirement already satisfied: python-dotenv in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from webdriver-manager) (0.21.1)\n",
"Requirement already satisfied: packaging in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from webdriver-manager) (23.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->webdriver-manager) (3.2.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->webdriver-manager) (2.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->webdriver-manager) (2.2.2)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->webdriver-manager) (2023.5.7)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: undetected-chromedriver in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (3.5.5)\n",
"Requirement already satisfied: selenium>=4.9.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from undetected-chromedriver) (4.13.0)\n",
"Requirement already satisfied: requests in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from undetected-chromedriver) (2.32.3)\n",
"Requirement already satisfied: websockets in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from undetected-chromedriver) (11.0.3)\n",
"Requirement already satisfied: urllib3<3,>=1.26 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium>=4.9.0->undetected-chromedriver) (2.2.2)\n",
"Requirement already satisfied: trio~=0.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium>=4.9.0->undetected-chromedriver) (0.22.2)\n",
"Requirement already satisfied: trio-websocket~=0.9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium>=4.9.0->undetected-chromedriver) (0.11.1)\n",
"Requirement already satisfied: certifi>=2021.10.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from selenium>=4.9.0->undetected-chromedriver) (2023.5.7)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->undetected-chromedriver) (3.2.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->undetected-chromedriver) (2.10)\n",
"Requirement already satisfied: attrs>=20.1.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (23.1.0)\n",
"Requirement already satisfied: sortedcontainers in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (2.4.0)\n",
"Requirement already satisfied: outcome in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (1.2.0)\n",
"Requirement already satisfied: sniffio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (1.3.0)\n",
"Requirement already satisfied: cffi>=1.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (1.15.1)\n",
"Requirement already satisfied: exceptiongroup>=1.0.0rc9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (1.1.3)\n",
"Requirement already satisfied: wsproto>=0.14 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from trio-websocket~=0.9->selenium>=4.9.0->undetected-chromedriver) (1.2.0)\n",
"Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from urllib3[socks]<3,>=1.26->selenium>=4.9.0->undetected-chromedriver) (1.7.1)\n",
"Requirement already satisfied: pycparser in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from cffi>=1.14->trio~=0.17->selenium>=4.9.0->undetected-chromedriver) (2.21)\n",
"Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium>=4.9.0->undetected-chromedriver) (0.12.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: scikit-image in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (0.22.0)\n",
"Requirement already satisfied: numpy>=1.22 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (1.24.3)\n",
"Requirement already satisfied: scipy>=1.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (1.11.2)\n",
"Requirement already satisfied: networkx>=2.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (3.1)\n",
"Requirement already satisfied: pillow>=9.0.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (10.3.0)\n",
"Requirement already satisfied: imageio>=2.27 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (2.31.5)\n",
"Requirement already satisfied: tifffile>=2022.8.12 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (2023.9.26)\n",
"Requirement already satisfied: packaging>=21 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (23.2)\n",
"Requirement already satisfied: lazy_loader>=0.3 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from scikit-image) (0.3)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: user_agent in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (0.1.10)\n",
"Requirement already satisfied: six in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from user_agent) (1.16.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: pyautogui in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (0.9.54)\n",
"Requirement already satisfied: pymsgbox in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyautogui) (1.0.9)\n",
"Requirement already satisfied: pytweening>=1.0.4 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyautogui) (1.2.0)\n",
"Requirement already satisfied: pyscreeze>=0.1.21 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyautogui) (0.1.30)\n",
"Requirement already satisfied: pygetwindow>=0.0.5 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyautogui) (0.0.9)\n",
"Requirement already satisfied: mouseinfo in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyautogui) (0.1.3)\n",
"Requirement already satisfied: pyrect in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pygetwindow>=0.0.5->pyautogui) (0.2.0)\n",
"Requirement already satisfied: Pillow>=9.2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyscreeze>=0.1.21->pyautogui) (10.3.0)\n",
"Requirement already satisfied: pyperclip in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from mouseinfo->pyautogui) (1.8.2)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: pillow in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (10.3.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: gradio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (4.37.2)\n",
"Requirement already satisfied: aiofiles<24.0,>=22.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (23.2.1)\n",
"Requirement already satisfied: altair<6.0,>=4.2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (5.0.1)\n",
"Requirement already satisfied: fastapi in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.111.0)\n",
"Requirement already satisfied: ffmpy in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.3.2)\n",
"Requirement already satisfied: gradio-client==1.0.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (1.0.2)\n",
"Requirement already satisfied: httpx>=0.24.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.25.1)\n",
"Requirement already satisfied: huggingface-hub>=0.19.3 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.23.4)\n",
"Requirement already satisfied: importlib-resources<7.0,>=1.3 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (6.1.0)\n",
"Requirement already satisfied: jinja2<4.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (3.1.2)\n",
"Requirement already satisfied: markupsafe~=2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (2.1.3)\n",
"Requirement already satisfied: matplotlib~=3.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (3.7.2)\n",
"Requirement already satisfied: numpy<3.0,>=1.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (1.24.3)\n",
"Requirement already satisfied: orjson~=3.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (3.10.3)\n",
"Requirement already satisfied: packaging in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (23.2)\n",
"Requirement already satisfied: pandas<3.0,>=1.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (2.0.2)\n",
"Requirement already satisfied: pillow<11.0,>=8.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (10.3.0)\n",
"Requirement already satisfied: pydantic>=2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (2.7.4)\n",
"Requirement already satisfied: pydub in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.25.1)\n",
"Requirement already satisfied: python-multipart>=0.0.9 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.0.9)\n",
"Requirement already satisfied: pyyaml<7.0,>=5.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (6.0.1)\n",
"Requirement already satisfied: ruff>=0.2.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.4.10)\n",
"Requirement already satisfied: semantic-version~=2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (2.10.0)\n",
"Requirement already satisfied: tomlkit==0.12.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.12.0)\n",
"Requirement already satisfied: typer<1.0,>=0.12 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.12.3)\n",
"Requirement already satisfied: typing-extensions~=4.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (4.12.1)\n",
"Requirement already satisfied: urllib3~=2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (2.2.2)\n",
"Requirement already satisfied: uvicorn>=0.14.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio) (0.30.1)\n",
"Requirement already satisfied: fsspec in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio-client==1.0.2->gradio) (2023.9.2)\n",
"Requirement already satisfied: websockets<12.0,>=10.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gradio-client==1.0.2->gradio) (11.0.3)\n",
"Requirement already satisfied: jsonschema>=3.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from altair<6.0,>=4.2.0->gradio) (3.2.0)\n",
"Requirement already satisfied: toolz in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from altair<6.0,>=4.2.0->gradio) (0.12.0)\n",
"Requirement already satisfied: anyio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx>=0.24.1->gradio) (3.7.1)\n",
"Requirement already satisfied: certifi in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx>=0.24.1->gradio) (2023.5.7)\n",
"Requirement already satisfied: httpcore in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx>=0.24.1->gradio) (0.13.7)\n",
"Requirement already satisfied: idna in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx>=0.24.1->gradio) (2.10)\n",
"Requirement already satisfied: sniffio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx>=0.24.1->gradio) (1.3.0)\n",
"Requirement already satisfied: filelock in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from huggingface-hub>=0.19.3->gradio) (3.12.0)\n",
"Requirement already satisfied: requests in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\n",
"Requirement already satisfied: tqdm>=4.42.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from huggingface-hub>=0.19.3->gradio) (4.66.4)\n",
"Requirement already satisfied: contourpy>=1.0.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (1.0.7)\n",
"Requirement already satisfied: cycler>=0.10 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (0.11.0)\n",
"Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (4.39.4)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (1.4.4)\n",
"Requirement already satisfied: pyparsing<3.1,>=2.3.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (3.0.9)\n",
"Requirement already satisfied: python-dateutil>=2.7 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pandas<3.0,>=1.0->gradio) (2022.7.1)\n",
"Requirement already satisfied: tzdata>=2022.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pandas<3.0,>=1.0->gradio) (2023.3)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pydantic>=2.0->gradio) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.18.4 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pydantic>=2.0->gradio) (2.18.4)\n",
"Requirement already satisfied: click>=8.0.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from typer<1.0,>=0.12->gradio) (8.1.3)\n",
"Requirement already satisfied: shellingham>=1.3.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from typer<1.0,>=0.12->gradio) (1.5.0.post1)\n",
"Requirement already satisfied: rich>=10.11.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from typer<1.0,>=0.12->gradio) (13.4.1)\n",
"Requirement already satisfied: h11>=0.8 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from uvicorn>=0.14.0->gradio) (0.12.0)\n",
"Requirement already satisfied: starlette<0.38.0,>=0.37.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from fastapi->gradio) (0.37.2)\n",
"Requirement already satisfied: fastapi-cli>=0.0.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from fastapi->gradio) (0.0.4)\n",
"Requirement already satisfied: ujson!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,>=4.0.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from fastapi->gradio) (5.10.0)\n",
"Requirement already satisfied: email_validator>=2.0.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from fastapi->gradio) (2.2.0)\n",
"Requirement already satisfied: colorama in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from click>=8.0.0->typer<1.0,>=0.12->gradio) (0.4.6)\n",
"Requirement already satisfied: dnspython>=2.0.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from email_validator>=2.0.0->fastapi->gradio) (2.6.1)\n",
"Requirement already satisfied: attrs>=17.4.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (23.1.0)\n",
"Requirement already satisfied: pyrsistent>=0.14.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.19.3)\n",
"Requirement already satisfied: setuptools in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (70.0.0)\n",
"Requirement already satisfied: six>=1.11.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (1.16.0)\n",
"Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.2.0)\n",
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.15.1)\n",
"Requirement already satisfied: exceptiongroup in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from anyio->httpx>=0.24.1->gradio) (1.1.3)\n",
"Requirement already satisfied: httptools>=0.5.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from uvicorn[standard]>=0.12.0->fastapi->gradio) (0.6.1)\n",
"Requirement already satisfied: python-dotenv>=0.13 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from uvicorn[standard]>=0.12.0->fastapi->gradio) (0.21.1)\n",
"Requirement already satisfied: watchfiles>=0.13 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from uvicorn[standard]>=0.12.0->fastapi->gradio) (0.22.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.2.0)\n",
"Requirement already satisfied: mdurl~=0.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from markdown-it-py<3.0.0,>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: pyngrok in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (7.1.6)\n",
"Requirement already satisfied: PyYAML>=5.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from pyngrok) (6.0.1)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: transformers in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (4.41.2)\n",
"Requirement already satisfied: filelock in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (3.12.0)\n",
"Requirement already satisfied: huggingface-hub<1.0,>=0.23.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (0.23.4)\n",
"Requirement already satisfied: numpy>=1.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (1.24.3)\n",
"Requirement already satisfied: packaging>=20.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (23.2)\n",
"Requirement already satisfied: pyyaml>=5.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (6.0.1)\n",
"Requirement already satisfied: regex!=2019.12.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (2023.8.8)\n",
"Requirement already satisfied: requests in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (2.32.3)\n",
"Requirement already satisfied: tokenizers<0.20,>=0.19 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (0.19.1)\n",
"Requirement already satisfied: safetensors>=0.4.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (0.4.3)\n",
"Requirement already satisfied: tqdm>=4.27 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from transformers) (4.66.4)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from huggingface-hub<1.0,>=0.23.0->transformers) (2023.9.2)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from huggingface-hub<1.0,>=0.23.0->transformers) (4.12.1)\n",
"Requirement already satisfied: colorama in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from tqdm>=4.27->transformers) (0.4.6)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->transformers) (3.2.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->transformers) (2.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->transformers) (2.2.2)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from requests->transformers) (2023.5.7)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: torch in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (2.0.1)\n",
"Requirement already satisfied: filelock in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from torch) (3.12.0)\n",
"Requirement already satisfied: typing-extensions in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from torch) (4.12.1)\n",
"Requirement already satisfied: sympy in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from torch) (1.12)\n",
"Requirement already satisfied: networkx in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from torch) (3.1)\n",
"Requirement already satisfied: jinja2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from torch) (3.1.2)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from jinja2->torch) (2.1.3)\n",
"Requirement already satisfied: mpmath>=0.19 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from sympy->torch) (1.3.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: pillow in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (10.3.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: gevent==22.10.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (22.10.2)\n",
"Requirement already satisfied: zope.event in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gevent==22.10.2) (5.0)\n",
"Requirement already satisfied: zope.interface in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gevent==22.10.2) (6.4.post2)\n",
"Requirement already satisfied: setuptools in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gevent==22.10.2) (70.0.0)\n",
"Requirement already satisfied: greenlet>=2.0.0 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gevent==22.10.2) (2.0.2)\n",
"Requirement already satisfied: cffi>=1.12.2 in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from gevent==22.10.2) (1.15.1)\n",
"Requirement already satisfied: pycparser in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from cffi>=1.12.2->gevent==22.10.2) (2.21)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install selenium\n",
"%pip install selenium chromedriver-autoinstaller\n",
"%pip install webdriver-manager\n",
"%pip install undetected-chromedriver\n",
"%pip install scikit-image\n",
"%pip install user_agent\n",
"%pip install pyautogui\n",
"%pip install pillow\n",
"%pip install --upgrade gradio\n",
"%pip install pyngrok\n",
"%pip install transformers\n",
"%pip install torch\n",
"%pip install pillow\n",
"%pip install gevent==22.10.2\n",
"%pip install --upgrade httpx"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: httpx in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (0.25.1)\n",
"Collecting httpx\n",
" Downloading httpx-0.27.0-py3-none-any.whl.metadata (7.2 kB)\n",
"Requirement already satisfied: anyio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx) (3.7.1)\n",
"Requirement already satisfied: certifi in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx) (2023.5.7)\n",
"Collecting httpcore==1.* (from httpx)\n",
" Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)\n",
"Requirement already satisfied: idna in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx) (2.10)\n",
"Requirement already satisfied: sniffio in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from httpx) (1.3.0)\n",
"Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx)\n",
" Downloading h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)\n",
"Requirement already satisfied: exceptiongroup in c:\\users\\shash\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\\localcache\\local-packages\\python310\\site-packages (from anyio->httpx) (1.1.3)\n",
"Downloading httpx-0.27.0-py3-none-any.whl (75 kB)\n",
" ---------------------------------------- 0.0/75.6 kB ? eta -:--:--\n",
" ---------------------------------------- 75.6/75.6 kB 2.1 MB/s eta 0:00:00\n",
"Downloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n",
" ---------------------------------------- 0.0/77.9 kB ? eta -:--:--\n",
" ------------------------------- -------- 61.4/77.9 kB ? eta -:--:--\n",
" ---------------------------------------- 77.9/77.9 kB 1.1 MB/s eta 0:00:00\n",
"Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
" ---------------------------------------- 0.0/58.3 kB ? eta -:--:--\n",
" ---------------------------------------- 58.3/58.3 kB 3.2 MB/s eta 0:00:00\n",
"Installing collected packages: h11, httpcore, httpx\n",
" Attempting uninstall: h11\n",
" Found existing installation: h11 0.12.0\n",
" Uninstalling h11-0.12.0:\n",
" Successfully uninstalled h11-0.12.0\n",
" Attempting uninstall: httpcore\n",
" Found existing installation: httpcore 0.13.7\n",
" Uninstalling httpcore-0.13.7:\n",
" Successfully uninstalled httpcore-0.13.7\n",
" Attempting uninstall: httpx\n",
" Found existing installation: httpx 0.25.1\n",
" Uninstalling httpx-0.25.1:\n",
" Successfully uninstalled httpx-0.25.1\n",
"Successfully installed h11-0.14.0 httpcore-1.0.5 httpx-0.27.0\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install --upgrade httpx"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from PIL import Image\n",
"import os\n",
"import random\n",
"import shutil\n",
"import re\n",
"import requests\n",
"import time\n",
"from time import sleep\n",
"import pyautogui\n",
"import base64\n",
"import undetected_chromedriver as uc\n",
"from selenium import webdriver\n",
"from selenium.webdriver.common.by import By\n",
"from selenium.webdriver.support.ui import WebDriverWait\n",
"from selenium.webdriver.support import expected_conditions as EC\n",
"from selenium.webdriver.common.action_chains import ActionChains\n",
"from selenium.webdriver.common.keys import Keys\n",
"import gradio as gr\n",
"from pyngrok import ngrok\n",
"from transformers import CLIPProcessor, CLIPModel\n",
"import torch\n",
"from transformers import AutoProcessor\n",
"from transformers import AutoProcessor, Kosmos2ForConditionalGeneration"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "RuntimeError",
"evalue": "[enforce fail at ..\\c10\\core\\impl\\alloc_cpu.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 67108864 bytes.",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[2], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# Initialize Kosmos model and processor\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mKosmos2ForConditionalGeneration\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_pretrained\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmicrosoft/kosmos-2-patch14-224\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 3\u001b[0m processor \u001b[38;5;241m=\u001b[39m AutoProcessor\u001b[38;5;241m.\u001b[39mfrom_pretrained(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmicrosoft/kosmos-2-patch14-224\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\modeling_utils.py:3626\u001b[0m, in \u001b[0;36mPreTrainedModel.from_pretrained\u001b[1;34m(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)\u001b[0m\n\u001b[0;32m 3620\u001b[0m config \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m_autoset_attn_implementation(\n\u001b[0;32m 3621\u001b[0m config, use_flash_attention_2\u001b[38;5;241m=\u001b[39muse_flash_attention_2, torch_dtype\u001b[38;5;241m=\u001b[39mtorch_dtype, device_map\u001b[38;5;241m=\u001b[39mdevice_map\n\u001b[0;32m 3622\u001b[0m )\n\u001b[0;32m 3624\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m ContextManagers(init_contexts):\n\u001b[0;32m 3625\u001b[0m \u001b[38;5;66;03m# Let's make sure we don't run the init function of buffer modules\u001b[39;00m\n\u001b[1;32m-> 3626\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mcls\u001b[39m(config, \u001b[38;5;241m*\u001b[39mmodel_args, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mmodel_kwargs)\n\u001b[0;32m 3628\u001b[0m \u001b[38;5;66;03m# make sure we use the model's config since the __init__ call might have copied it\u001b[39;00m\n\u001b[0;32m 3629\u001b[0m config \u001b[38;5;241m=\u001b[39m model\u001b[38;5;241m.\u001b[39mconfig\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:1876\u001b[0m, in \u001b[0;36mKosmos2ForConditionalGeneration.__init__\u001b[1;34m(self, config)\u001b[0m\n\u001b[0;32m 1873\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, config: Kosmos2Config):\n\u001b[0;32m 1874\u001b[0m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__init__\u001b[39m(config)\n\u001b[1;32m-> 1876\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtext_model \u001b[38;5;241m=\u001b[39m \u001b[43mKosmos2TextForCausalLM\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtext_config\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1877\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvision_model \u001b[38;5;241m=\u001b[39m Kosmos2VisionModel(config\u001b[38;5;241m.\u001b[39mvision_config)\n\u001b[0;32m 1879\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mimage_to_text_projection \u001b[38;5;241m=\u001b[39m Kosmos2ImageToTextProjection(config)\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:1532\u001b[0m, in \u001b[0;36mKosmos2TextForCausalLM.__init__\u001b[1;34m(self, config)\u001b[0m\n\u001b[0;32m 1529\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, config: Kosmos2TextConfig):\n\u001b[0;32m 1530\u001b[0m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__init__\u001b[39m(config)\n\u001b[1;32m-> 1532\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel \u001b[38;5;241m=\u001b[39m \u001b[43mKosmos2TextTransformer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1533\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlm_head \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLinear(in_features\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39membed_dim, out_features\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mvocab_size, bias\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m 1535\u001b[0m \u001b[38;5;66;03m# Initialize weights and apply final processing\u001b[39;00m\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:1105\u001b[0m, in \u001b[0;36mKosmos2TextTransformer.__init__\u001b[1;34m(self, config)\u001b[0m\n\u001b[0;32m 1097\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_tokens \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mEmbedding(config\u001b[38;5;241m.\u001b[39mvocab_size, config\u001b[38;5;241m.\u001b[39membed_dim, padding_idx\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mpad_token_id)\n\u001b[0;32m 1099\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_positions \u001b[38;5;241m=\u001b[39m Kosmos2TextSinusoidalPositionalEmbedding(\n\u001b[0;32m 1100\u001b[0m num_positions\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mmax_position_embeddings,\n\u001b[0;32m 1101\u001b[0m embedding_dim\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39membed_dim,\n\u001b[0;32m 1102\u001b[0m padding_idx\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mpad_token_id,\n\u001b[0;32m 1103\u001b[0m )\n\u001b[1;32m-> 1105\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayers \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mModuleList([Kosmos2TextBlock(config) \u001b[38;5;28;01mfor\u001b[39;00m _ \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(config\u001b[38;5;241m.\u001b[39mlayers)])\n\u001b[0;32m 1106\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayer_norm \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLayerNorm(config\u001b[38;5;241m.\u001b[39membed_dim, config\u001b[38;5;241m.\u001b[39mlayer_norm_eps)\n\u001b[0;32m 1108\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgradient_checkpointing \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:1105\u001b[0m, in \u001b[0;36m<listcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m 1097\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_tokens \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mEmbedding(config\u001b[38;5;241m.\u001b[39mvocab_size, config\u001b[38;5;241m.\u001b[39membed_dim, padding_idx\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mpad_token_id)\n\u001b[0;32m 1099\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_positions \u001b[38;5;241m=\u001b[39m Kosmos2TextSinusoidalPositionalEmbedding(\n\u001b[0;32m 1100\u001b[0m num_positions\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mmax_position_embeddings,\n\u001b[0;32m 1101\u001b[0m embedding_dim\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39membed_dim,\n\u001b[0;32m 1102\u001b[0m padding_idx\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mpad_token_id,\n\u001b[0;32m 1103\u001b[0m )\n\u001b[1;32m-> 1105\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayers \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mModuleList([\u001b[43mKosmos2TextBlock\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mfor\u001b[39;00m _ \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(config\u001b[38;5;241m.\u001b[39mlayers)])\n\u001b[0;32m 1106\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayer_norm \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLayerNorm(config\u001b[38;5;241m.\u001b[39membed_dim, config\u001b[38;5;241m.\u001b[39mlayer_norm_eps)\n\u001b[0;32m 1108\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgradient_checkpointing \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:998\u001b[0m, in \u001b[0;36mKosmos2TextBlock.__init__\u001b[1;34m(self, config)\u001b[0m\n\u001b[0;32m 988\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencoder_attn \u001b[38;5;241m=\u001b[39m KosmosTextAttention(\n\u001b[0;32m 989\u001b[0m config,\n\u001b[0;32m 990\u001b[0m embed_dim\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_dim,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 994\u001b[0m add_inner_attn_layernorm\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 995\u001b[0m )\n\u001b[0;32m 996\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencoder_attn_layer_norm \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLayerNorm(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_dim, eps\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mlayer_norm_eps)\n\u001b[1;32m--> 998\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mffn \u001b[38;5;241m=\u001b[39m \u001b[43mKosmos2TextFFN\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 999\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfinal_layer_norm \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLayerNorm(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membed_dim, eps\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mlayer_norm_eps)\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\kosmos2\\modeling_kosmos2.py:956\u001b[0m, in \u001b[0;36mKosmos2TextFFN.__init__\u001b[1;34m(self, config)\u001b[0m\n\u001b[0;32m 953\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mactivation_fn \u001b[38;5;241m=\u001b[39m ACT2FN[config\u001b[38;5;241m.\u001b[39mactivation_function]\n\u001b[0;32m 954\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mactivation_dropout \u001b[38;5;241m=\u001b[39m config\u001b[38;5;241m.\u001b[39mactivation_dropout\n\u001b[1;32m--> 956\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfc1 \u001b[38;5;241m=\u001b[39m \u001b[43mnn\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mLinear\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43membed_dim\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mffn_dim\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 957\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfc2 \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLinear(config\u001b[38;5;241m.\u001b[39mffn_dim, config\u001b[38;5;241m.\u001b[39membed_dim)\n\u001b[0;32m 959\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mffn_layernorm \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mLayerNorm(config\u001b[38;5;241m.\u001b[39mffn_dim, eps\u001b[38;5;241m=\u001b[39mconfig\u001b[38;5;241m.\u001b[39mlayer_norm_eps)\n",
"File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\nn\\modules\\linear.py:96\u001b[0m, in \u001b[0;36mLinear.__init__\u001b[1;34m(self, in_features, out_features, bias, device, dtype)\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39min_features \u001b[38;5;241m=\u001b[39m in_features\n\u001b[0;32m 95\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mout_features \u001b[38;5;241m=\u001b[39m out_features\n\u001b[1;32m---> 96\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mweight \u001b[38;5;241m=\u001b[39m Parameter(torch\u001b[38;5;241m.\u001b[39mempty((out_features, in_features), \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mfactory_kwargs))\n\u001b[0;32m 97\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m bias:\n\u001b[0;32m 98\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbias \u001b[38;5;241m=\u001b[39m Parameter(torch\u001b[38;5;241m.\u001b[39mempty(out_features, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mfactory_kwargs))\n",
"\u001b[1;31mRuntimeError\u001b[0m: [enforce fail at ..\\c10\\core\\impl\\alloc_cpu.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 67108864 bytes."
]
}
],
"source": [
"# Initialize Kosmos model and processor\n",
"model = Kosmos2ForConditionalGeneration.from_pretrained(\"microsoft/kosmos-2-patch14-224\")\n",
"processor = AutoProcessor.from_pretrained(\"microsoft/kosmos-2-patch14-224\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Traceback (most recent call last):\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\queueing.py\", line 541, in process_events\n",
" response = await route_utils.call_process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\route_utils.py\", line 276, in call_process_api\n",
" output = await app.get_blocks().process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1928, in process_api\n",
" result = await self.call_function(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1514, in call_function\n",
" prediction = await anyio.to_thread.run_sync(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\to_thread.py\", line 56, in run_sync\n",
" return await get_async_backend().run_sync_in_worker_thread(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 2144, in run_sync_in_worker_thread\n",
" return await future\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 851, in run\n",
" result = context.run(func, *args)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\utils.py\", line 833, in wrapper\n",
" response = f(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 95, in display_image\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 67, in process_images\n",
" prompt = generate_prompt(image_names[0])\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 21, in generate_prompt\n",
" outputs = clip_model(**inputs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\nn\\modules\\module.py\", line 1501, in _call_impl\n",
" return forward_call(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\clip\\modeling_clip.py\", line 1118, in forward\n",
" text_outputs = self.text_model(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\nn\\modules\\module.py\", line 1501, in _call_impl\n",
" return forward_call(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\clip\\modeling_clip.py\", line 694, in forward\n",
" raise ValueError(\"You have to specify input_ids\")\n",
"ValueError: You have to specify input_ids\n",
"Traceback (most recent call last):\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\queueing.py\", line 541, in process_events\n",
" response = await route_utils.call_process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\route_utils.py\", line 276, in call_process_api\n",
" output = await app.get_blocks().process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1928, in process_api\n",
" result = await self.call_function(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1514, in call_function\n",
" prediction = await anyio.to_thread.run_sync(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\to_thread.py\", line 56, in run_sync\n",
" return await get_async_backend().run_sync_in_worker_thread(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 2144, in run_sync_in_worker_thread\n",
" return await future\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 851, in run\n",
" result = context.run(func, *args)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\utils.py\", line 833, in wrapper\n",
" response = f(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 95, in display_image\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 67, in process_images\n",
" prompt = generate_prompt(image_names[0])\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_32144\\2398520208.py\", line 21, in generate_prompt\n",
" outputs = clip_model(**inputs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\nn\\modules\\module.py\", line 1501, in _call_impl\n",
" return forward_call(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\clip\\modeling_clip.py\", line 1118, in forward\n",
" text_outputs = self.text_model(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\nn\\modules\\module.py\", line 1501, in _call_impl\n",
" return forward_call(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\models\\clip\\modeling_clip.py\", line 694, in forward\n",
" raise ValueError(\"You have to specify input_ids\")\n",
"ValueError: You have to specify input_ids\n"
]
}
],
"source": [
"# Initialize the CLIP model and processor\n",
"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
"clip_model = CLIPModel.from_pretrained(\"openai/clip-vit-base-patch32\").to(device)\n",
"clip_processor = CLIPProcessor.from_pretrained(\"openai/clip-vit-base-patch32\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from selenium.common.exceptions import WebDriverException\n",
"from webdriver_manager.chrome import ChromeDriverManager\n",
"\n",
"# Get the current working directory\n",
"current_dir = os.getcwd()\n",
"# Define download directory within the Midjourney folder\n",
"download_dir = os.path.join(current_dir, 'Midjourney_Visual')\n",
"if not os.path.exists(download_dir):\n",
" os.makedirs(download_dir)\n",
" \n",
"# Define Chrome options and experimental preferences\n",
"options = uc.ChromeOptions()\n",
"\n",
"options = uc.ChromeOptions()\n",
"options.add_argument('--no-sandbox')\n",
"options.add_argument('--disable-dev-shm-usage')\n",
"options.add_argument('--disable-blink-features=AutomationControlled')\n",
"options.add_argument(\"--disable-popup-blocking\")\n",
"\n",
"prefs = {\n",
" \"profile.default_content_settings.popups\": 0,\n",
" \"profile.content_settings.pattern_pairs.*.multiple-automatic-downloads\": 1,\n",
" \"download.prompt_for_download\": False,\n",
" \"download.default_directory\": download_dir\n",
"}\n",
"options.add_experimental_option(\"prefs\", prefs)\n",
"\n",
"try:\n",
" # Use webdriver_manager to automatically download and manage ChromeDriver\n",
" driver_path = ChromeDriverManager().install()\n",
" driver = uc.Chrome(options=options, driver_executable_path=driver_path)\n",
" driver.get(\"https://discord.com/login\")\n",
"except WebDriverException as e:\n",
" print(f\"An error occurred while initializing the WebDriver: {e}\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"driver.maximize_window();\n",
"driver.get(\"https://discord.com/channels/1155301271088152709/1238313627266711573\")\n",
"time.sleep(5)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7861\n",
"\n",
"Could not create share link. Please check your internet connection or our status page: https://status.gradio.app.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def save_base64_image(base64_str, file_name):\n",
" header, encoded = base64_str.split(',', 1)\n",
" data = base64.b64decode(encoded)\n",
" with open(file_name, \"wb\") as f:\n",
" f.write(data)\n",
" print(f\"Base64 image {file_name} saved successfully\")\n",
"\n",
"# Function to upload image and get the new URL\n",
"def reupload_image(image_path, driver, div_element):\n",
" t = f\"!upload_image {image_path}\"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(4, 5))\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay__35a04')[-1]\n",
" return latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
"# Function to generate prompt using CLIP model\n",
"def generate_prompt(image_path):\n",
" image = Image.open(image_path)\n",
" inputs = clip_processor(images=image, return_tensors=\"pt\").to(device)\n",
" outputs = clip_model(**inputs)\n",
" logits_per_image = outputs.logits_per_image\n",
" probs = logits_per_image.softmax(dim=-1)\n",
" # Get the text corresponding to the highest probability\n",
" text_idx = torch.argmax(probs).item()\n",
" prompt = clip_processor.tokenizer.decode([text_idx])\n",
" print(f\"Generated prompt: {prompt}\")\n",
" return prompt\n",
"\n",
"# Function to handle user input, upload images, send prompts, and download images\n",
"def process_images(prompt, image1, image2=None):\n",
" if not os.path.exists('Demo_Visual'):\n",
" os.makedirs('Demo_Visual')\n",
"\n",
" image_names = []\n",
" for idx, image in enumerate([image1, image2]):\n",
" if image is not None:\n",
" image_name = f\"Image_{idx + 1}.jpg\"\n",
" image.save(image_name)\n",
" image_names.append(image_name)\n",
"\n",
" filename = os.path.basename(image_name)\n",
"\n",
" t = f\"!upload_image {filename}\"\n",
" div_element = driver.find_element(By.CSS_SELECTOR, 'div[data-slate-node=\"element\"]')\n",
"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(5, 6))\n",
"\n",
" image_srcs = []\n",
" latest_div_elements = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-len(image_names):]\n",
" for latest_div_element in latest_div_elements:\n",
" image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" if \"data:image\" in image_src:\n",
" save_base64_image(image_src, image_name)\n",
" new_image_src = reupload_image(image_name, driver, div_element)\n",
" image_srcs.append(new_image_src)\n",
" else:\n",
" image_srcs.append(image_src)\n",
"\n",
" driver.switch_to.window(driver.window_handles[0])\n",
"\n",
" time.sleep(random.uniform(1, 2))\n",
" ActionChains(driver).send_keys(\"/imagine \").perform()\n",
" time.sleep(random.uniform(0.4, 0.6))\n",
"\n",
" if not prompt:\n",
" prompt = generate_prompt(image_names[0])\n",
"\n",
" combined_text = \" \".join(image_srcs) + f\" {prompt}\".strip()\n",
" ActionChains(driver).send_keys(combined_text).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
"\n",
" time.sleep(random.uniform(0.5, 1))\n",
"\n",
" # Wait for the image to be generated\n",
" time.sleep(random.uniform(60, 80))\n",
"\n",
" # Download the generated image\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-1]\n",
" generated_image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" response = requests.get(generated_image_src)\n",
" if response.status_code == 200:\n",
" download_image_name = \"Demo_Visual/generated_image.png\"\n",
" with open(download_image_name, \"wb\") as f:\n",
" f.write(response.content)\n",
" print(f\"Image {download_image_name} saved successfully\")\n",
" return download_image_name\n",
" else:\n",
" print(f\"Failed to download the image for prompt {prompt}\")\n",
" return None\n",
"\n",
"# Function to display the image using Gradio\n",
"def display_image(prompt, image1, image2=None):\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" \n",
" if generated_image_path:\n",
" return Image.open(generated_image_path)\n",
" else:\n",
" return None\n",
"\n",
"# Create the Gradio interface\n",
"iface = gr.Interface(\n",
" fn=display_image,\n",
" inputs=[\"text\", gr.Image(type=\"pil\"), gr.Image(type=\"pil\", label=\"Optional Image\")],\n",
" outputs=\"image\",\n",
" title=\"Image Upload and Prompt Processing\",\n",
" description=\"Upload 1 or 2 images and enter a prompt. If no prompt is given, a prompt will be generated for you.\"\n",
")\n",
"\n",
"# Launch the interface in a Jupyter Notebook\n",
"iface.launch(inline=True, share=True)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7869\n",
"\n",
"Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
"Running on public URL: https://d578d221e4ae40e93a.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://d578d221e4ae40e93a.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Image Demo_Visual/generated_image.png saved successfully\n"
]
}
],
"source": [
"#Working Version\n",
"def save_base64_image(base64_str, file_name):\n",
" header, encoded = base64_str.split(',', 1)\n",
" data = base64.b64decode(encoded)\n",
" with open(file_name, \"wb\") as f:\n",
" f.write(data)\n",
" print(f\"Base64 image {file_name} saved successfully\")\n",
"\n",
"# Function to upload image and get the new URL\n",
"def reupload_image(image_path, driver, div_element):\n",
" t = f\"!upload_image {image_path}\"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(4, 5))\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay__35a04')[-1]\n",
" return latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
"# Function to handle user input, upload images, send prompts, and download images\n",
"def process_images(prompt, image1, image2=None):\n",
" if not os.path.exists('Demo_Visual'):\n",
" os.makedirs('Demo_Visual')\n",
"\n",
" image_names = []\n",
" for idx, image in enumerate([image1, image2]):\n",
" if image is not None:\n",
" image_name = f\"Demo_Visual/Image_{idx + 1}.jpg\"\n",
" image.save(image_name)\n",
" image_names.append(image_name)\n",
" filename = os.path.basename(image_name)\n",
"\n",
" t = f\"!upload_image {filename}\"\n",
" div_element = driver.find_element(By.CSS_SELECTOR, 'div[data-slate-node=\"element\"]')\n",
"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(5, 6))\n",
"\n",
" image_srcs = []\n",
" latest_div_elements = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-len(image_names):]\n",
" for latest_div_element in latest_div_elements:\n",
" image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" if \"data:image\" in image_src:\n",
" save_base64_image(image_src, image_name)\n",
" new_image_src = reupload_image(image_name, driver, div_element)\n",
" image_srcs.append(new_image_src)\n",
" else:\n",
" image_srcs.append(image_src)\n",
"\n",
" driver.switch_to.window(driver.window_handles[0])\n",
"\n",
" time.sleep(random.uniform(1, 2))\n",
" ActionChains(driver).send_keys(\"/imagine \").perform()\n",
" time.sleep(random.uniform(0.4, 0.6))\n",
" prompt = prompt.strip() if prompt.strip() else \"An image\"\n",
" combined_text = \" \".join(image_srcs) + \" \"+ f\" {prompt}\".strip()\n",
" ActionChains(driver).send_keys(combined_text).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
"\n",
" time.sleep(random.uniform(0.5, 1))\n",
"\n",
" # Wait for the image to be generated\n",
" time.sleep(random.uniform(60, 80))\n",
"\n",
" # Download the generated image\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-1]\n",
" generated_image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" response = requests.get(generated_image_src)\n",
" if response.status_code == 200:\n",
" download_image_name = \"Demo_Visual/generated_image.png\"\n",
" with open(download_image_name, \"wb\") as f:\n",
" f.write(response.content)\n",
" print(f\"Image {download_image_name} saved successfully\")\n",
" return download_image_name\n",
" else:\n",
" print(f\"Failed to download the image for prompt {prompt}\")\n",
" return None\n",
"\n",
"# Function to display the image using Gradio\n",
"def display_image(prompt, image1, image2=None):\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" \n",
" if generated_image_path:\n",
" return Image.open(generated_image_path)\n",
" else:\n",
" return None\n",
"\n",
"# Create the Gradio interface\n",
"iface = gr.Interface(\n",
" fn=display_image,\n",
" inputs=[\"text\", gr.Image(type=\"pil\"), gr.Image(type=\"pil\", label=\"Optional Image\")],\n",
" outputs=gr.Image(type=\"pil\", label=\"Generated Image\", width=512, height=512),\n",
" title=\"Visual Paraphrase using Midjourney\",\n",
" description=\"Upload 1 or 2 images and enter a prompt. If no prompt is given, enter text will be placed instead.\"\n",
")\n",
"\n",
"# Launch the interface in a Jupyter Notebook\n",
"iface.launch(inline=True,share=True)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'gradio' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[23], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mgradio\u001b[49m\u001b[38;5;241m.\u001b[39mdeploy()\n",
"\u001b[1;31mNameError\u001b[0m: name 'gradio' is not defined"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7866\n",
"Running on public URL: https://a119ee40cb7fa800ec.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://a119ee40cb7fa800ec.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Traceback (most recent call last):\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\queueing.py\", line 541, in process_events\n",
" response = await route_utils.call_process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\route_utils.py\", line 276, in call_process_api\n",
" output = await app.get_blocks().process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1928, in process_api\n",
" result = await self.call_function(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1514, in call_function\n",
" prediction = await anyio.to_thread.run_sync(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\to_thread.py\", line 33, in run_sync\n",
" return await get_asynclib().run_sync_in_worker_thread(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
" return await future\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 807, in run\n",
" result = context.run(func, *args)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\utils.py\", line 833, in wrapper\n",
" response = f(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 109, in display_image\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 75, in process_images\n",
" prompt = generate_prompt(image_names[0])\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 26, in generate_prompt\n",
" image_embeds_position_mask=inputs[\"image_embeds_position_mask\"],\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\feature_extraction_utils.py\", line 86, in __getitem__\n",
" return self.data[item]\n",
"KeyError: 'image_embeds_position_mask'\n",
"Traceback (most recent call last):\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\queueing.py\", line 541, in process_events\n",
" response = await route_utils.call_process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\route_utils.py\", line 276, in call_process_api\n",
" output = await app.get_blocks().process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1928, in process_api\n",
" result = await self.call_function(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1514, in call_function\n",
" prediction = await anyio.to_thread.run_sync(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\to_thread.py\", line 33, in run_sync\n",
" return await get_asynclib().run_sync_in_worker_thread(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
" return await future\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 807, in run\n",
" result = context.run(func, *args)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\utils.py\", line 833, in wrapper\n",
" response = f(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 109, in display_image\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 75, in process_images\n",
" prompt = generate_prompt(image_names[0])\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 26, in generate_prompt\n",
" image_embeds_position_mask=inputs[\"image_embeds_position_mask\"],\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\feature_extraction_utils.py\", line 86, in __getitem__\n",
" return self.data[item]\n",
"KeyError: 'image_embeds_position_mask'\n",
"Traceback (most recent call last):\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\queueing.py\", line 541, in process_events\n",
" response = await route_utils.call_process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\route_utils.py\", line 276, in call_process_api\n",
" output = await app.get_blocks().process_api(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1928, in process_api\n",
" result = await self.call_function(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\blocks.py\", line 1514, in call_function\n",
" prediction = await anyio.to_thread.run_sync(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\to_thread.py\", line 33, in run_sync\n",
" return await get_asynclib().run_sync_in_worker_thread(\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
" return await future\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\anyio\\_backends\\_asyncio.py\", line 807, in run\n",
" result = context.run(func, *args)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\gradio\\utils.py\", line 833, in wrapper\n",
" response = f(*args, **kwargs)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 109, in display_image\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 75, in process_images\n",
" prompt = generate_prompt(image_names[0])\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Temp\\ipykernel_10480\\3601372427.py\", line 26, in generate_prompt\n",
" image_embeds_position_mask=inputs[\"image_embeds_position_mask\"],\n",
" File \"C:\\Users\\shash\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\transformers\\feature_extraction_utils.py\", line 86, in __getitem__\n",
" return self.data[item]\n",
"KeyError: 'image_embeds_position_mask'\n"
]
}
],
"source": [
"def save_base64_image(base64_str, file_name):\n",
" header, encoded = base64_str.split(',', 1)\n",
" data = base64.b64decode(encoded)\n",
" with open(file_name, \"wb\") as f:\n",
" f.write(data)\n",
" print(f\"Base64 image {file_name} saved successfully\")\n",
"\n",
"def reupload_image(image_path, driver, div_element):\n",
" t = f\"!upload_image {image_path}\"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(4, 5))\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay__35a04')[-1]\n",
" return latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
"def generate_prompt(image_path):\n",
" image = Image.open(image_path)\n",
" prompt = \"<grounding> An image of\"\n",
" inputs = processor(text=prompt, images=image, return_tensors=\"pt\")\n",
" \n",
" generated_ids = model.generate(\n",
" pixel_values=inputs[\"pixel_values\"],\n",
" input_ids=inputs[\"input_ids\"],\n",
" attention_mask=inputs[\"attention_mask\"],\n",
" image_embeds=None,\n",
" image_embeds_position_mask=inputs[\"image_embeds_position_mask\"],\n",
" use_cache=True,\n",
" max_new_tokens=64,\n",
" )\n",
" generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]\n",
" caption, _ = processor.post_process_generation(generated_text)\n",
" \n",
" print(f\"Generated prompt: {caption}\")\n",
" return caption\n",
"\n",
"def process_images(prompt, image1, image2=None):\n",
" if not os.path.exists('Demo_Visual'):\n",
" os.makedirs('Demo_Visual')\n",
"\n",
" image_names = []\n",
" for idx, image in enumerate([image1, image2]):\n",
" if image is not None:\n",
" image_name = f\"Image_{idx + 1}.jpg\"\n",
" image.save(image_name)\n",
" image_names.append(image_name)\n",
"\n",
" filename = os.path.basename(image_name)\n",
"\n",
" t = f\"!upload_image {filename}\"\n",
" div_element = driver.find_element(By.CSS_SELECTOR, 'div[data-slate-node=\"element\"]')\n",
"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(5, 6))\n",
"\n",
" image_srcs = []\n",
" latest_div_elements = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-len(image_names):]\n",
" for latest_div_element in latest_div_elements:\n",
" image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" if \"data:image\" in image_src:\n",
" save_base64_image(image_src, image_name)\n",
" new_image_src = reupload_image(image_name, driver, div_element)\n",
" image_srcs.append(new_image_src)\n",
" else:\n",
" image_srcs.append(image_src)\n",
"\n",
" driver.switch_to.window(driver.window_handles[0])\n",
"\n",
" time.sleep(random.uniform(1, 2))\n",
" ActionChains(driver).send_keys(\"/imagine \").perform()\n",
" time.sleep(random.uniform(0.4, 0.6))\n",
"\n",
" if not prompt:\n",
" prompt = generate_prompt(image_names[0])\n",
"\n",
" combined_text = \" \".join(image_srcs) + f\" {prompt}\".strip()\n",
" ActionChains(driver).send_keys(combined_text).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
"\n",
" time.sleep(random.uniform(0.5, 1))\n",
"\n",
" # Wait for the image to be generated\n",
" time.sleep(random.uniform(60, 80))\n",
"\n",
" # Download the generated image\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-1]\n",
" generated_image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" response = requests.get(generated_image_src)\n",
" if response.status_code == 200:\n",
" download_image_name = \"Demo_Visual/generated_image.png\"\n",
" with open(download_image_name, \"wb\") as f:\n",
" f.write(response.content)\n",
" print(f\"Image {download_image_name} saved successfully\")\n",
" \n",
" # Resize image to one-fourth of its current size\n",
" image = Image.open(download_image_name)\n",
" resized_image = image.resize((image.width // 4, image.height // 4))\n",
" resized_image.save(download_image_name)\n",
" print(f\"Image {download_image_name} resized successfully\")\n",
" \n",
" return download_image_name\n",
" else:\n",
" print(f\"Failed to download the image for prompt {prompt}\")\n",
" return None\n",
"\n",
"def display_image(prompt, image1, image2=None):\n",
" generated_image_path = process_images(prompt, image1, image2)\n",
" \n",
" if generated_image_path:\n",
" return Image.open(generated_image_path)\n",
" else:\n",
" return None\n",
"\n",
"# Create the Gradio interface\n",
"iface = gr.Interface(\n",
" fn=display_image,\n",
" inputs=[\"text\", gr.Image(type=\"pil\"), gr.Image(type=\"pil\", label=\"Optional Image\")],\n",
" outputs=gr.Image(type=\"pil\", label=\"Generated Image\", width=400, height=400),\n",
" title=\"Visual Paraphrase using Midjourney\",\n",
" description=\"Upload 1 or 2 images and enter a prompt. If no prompt is given, a prompt will be generated for you.\"\n",
")\n",
"\n",
"# Launch the interface in a Jupyter Notebook\n",
"iface.launch(inline=True, share=True)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7865\n",
"Running on public URL: https://3b5070f739396e53c1.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://3b5070f739396e53c1.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import base64\n",
"import os\n",
"import random\n",
"import time\n",
"import requests\n",
"from PIL import Image\n",
"from selenium.webdriver.common.action_chains import ActionChains\n",
"from selenium.webdriver.common.by import By\n",
"from selenium.webdriver.common.keys import Keys\n",
"import gradio as gr\n",
"from transformers import BlipProcessor, BlipForConditionalGeneration\n",
"import torch\n",
"\n",
"# Initialize the captioning model\n",
"processor = BlipProcessor.from_pretrained(\"Salesforce/blip-image-captioning-base\")\n",
"model = BlipForConditionalGeneration.from_pretrained(\"Salesforce/blip-image-captioning-base\")\n",
"\n",
"def save_base64_image(base64_str, file_name):\n",
" header, encoded = base64_str.split(',', 1)\n",
" data = base64.b64decode(encoded)\n",
" with open(file_name, \"wb\") as f:\n",
" f.write(data)\n",
" print(f\"Base64 image {file_name} saved successfully\")\n",
"\n",
"def reupload_image(image_path, driver, div_element):\n",
" t = f\"!upload_image {image_path}\"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(4, 5))\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay__35a04')[-1]\n",
" return latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
"def generate_caption(image_path):\n",
" image = Image.open(image_path).convert(\"RGB\")\n",
" inputs = processor(images=image, return_tensors=\"pt\")\n",
" outputs = model.generate(**inputs)\n",
" caption = processor.decode(outputs[0], skip_special_tokens=True)\n",
" return caption\n",
"\n",
"def process_images(image1, image2=None):\n",
" if not os.path.exists('Demo_Visual'):\n",
" os.makedirs('Demo_Visual')\n",
"\n",
" image_names = []\n",
" for idx, image in enumerate([image1, image2]):\n",
" if image is not None:\n",
" image_name = f\"Demo_Visual/Image_{idx + 1}.jpg\"\n",
" image.save(image_name)\n",
" image_names.append(image_name)\n",
" filename = os.path.basename(image_name)\n",
"\n",
" t = f\"!upload_image {filename}\"\n",
" div_element = driver.find_element(By.CSS_SELECTOR, 'div[data-slate-node=\"element\"]')\n",
"\n",
" ActionChains(driver).send_keys(t).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
" time.sleep(random.uniform(5, 6))\n",
"\n",
" image_srcs = []\n",
" latest_div_elements = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-len(image_names):]\n",
" for latest_div_element in latest_div_elements:\n",
" image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" if \"data:image\" in image_src:\n",
" save_base64_image(image_src, image_name)\n",
" new_image_src = reupload_image(image_name, driver, div_element)\n",
" image_srcs.append(new_image_src)\n",
" else:\n",
" image_srcs.append(image_src)\n",
"\n",
" driver.switch_to.window(driver.window_handles[0])\n",
"\n",
" time.sleep(random.uniform(1, 2))\n",
" ActionChains(driver).send_keys(\"/imagine \").perform()\n",
" time.sleep(random.uniform(0.4, 0.6))\n",
"\n",
" captions = [generate_caption(image_name) for image_name in image_names]\n",
" combined_text = \" \".join(image_srcs) + \" \" + \" \".join(captions)\n",
" ActionChains(driver).send_keys(combined_text).perform()\n",
" ActionChains(driver).send_keys(Keys.RETURN).perform()\n",
"\n",
" time.sleep(random.uniform(0.5, 1))\n",
" time.sleep(random.uniform(60, 80))\n",
"\n",
" latest_div_element = driver.find_elements(By.CSS_SELECTOR, 'div.loadingOverlay_d4597d')[-1]\n",
" generated_image_src = latest_div_element.find_element(By.TAG_NAME, 'img').get_attribute('src')\n",
"\n",
" response = requests.get(generated_image_src)\n",
" if response.status_code == 200:\n",
" download_image_name = \"Demo_Visual/generated_image.png\"\n",
" with open(download_image_name, \"wb\") as f:\n",
" f.write(response.content)\n",
" print(f\"Image {download_image_name} saved successfully\")\n",
" return download_image_name\n",
" else:\n",
" print(f\"Failed to download the image\")\n",
" return None\n",
"\n",
"def display_image(image1, image2=None):\n",
" generated_image_path = process_images(image1, image2)\n",
" \n",
" if generated_image_path:\n",
" return Image.open(generated_image_path)\n",
" else:\n",
" return None\n",
"\n",
"iface = gr.Interface(\n",
" fn=display_image,\n",
" inputs=[gr.Image(type=\"pil\"), gr.Image(type=\"pil\", label=\"Optional Image\")],\n",
" outputs=gr.Image(type=\"pil\", label=\"Generated Image\", width=256, height=256),\n",
" title=\"Visual Paraphrase using Midjourney\",\n",
" description=\"Upload 1 or 2 images and enter a prompt. If no prompt is given, a prompt will be generated for you.\"\n",
")\n",
"\n",
"iface.launch(inline=True, share=True)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|