parquet-converter commited on
Commit
dff5745
·
1 Parent(s): 897dd44

Update parquet files (step 102 of 121)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. spaces/1gistliPinn/ChatGPT4/((LINK)) Mimio Studio 9 12 Keygen Crack REPACK.md +0 -97
  2. spaces/1gistliPinn/ChatGPT4/Examples/Amberial Dreams Download LINK For PS.md +0 -94
  3. spaces/1gistliPinn/ChatGPT4/Examples/Apowersoft Screen Recorder Pro V2.1.9 Crack [CracksNow] Full Version HOT.md +0 -6
  4. spaces/1gistliPinn/ChatGPT4/Examples/Datta Chalisa In Telugu.pdf !FULL!.md +0 -6
  5. spaces/1line/AutoGPT/tests/milvus_memory_test.py +0 -72
  6. spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Bus Simulator Indonesia Experience the Authentic Driving in Indonesia on PC.md +0 -97
  7. spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Dj Neptune 80 39s Classic Old School Mix Mp3.md +0 -73
  8. spaces/801artistry/RVC801/lib/uvr5_pack/lib_v5/layers.py +0 -118
  9. spaces/AI4PD/hexviz/hexviz/plot.py +0 -94
  10. spaces/AIFILMS/audioldm-text-to-audio-generation/audioldm/latent_diffusion/ema.py +0 -81
  11. spaces/AIWaves/SOP_Generation-single/Action/base_action.py +0 -51
  12. spaces/AchyuthGamer/OpenGPT-Chat-UI/src/styles/highlight-js.css +0 -1
  13. spaces/AchyuthGamer/OpenGPT/client/js/highlightjs-copy.min.js +0 -1
  14. spaces/AchyuthGamer/jondurbin-airoboros-gpt-3.5-turbo-100k-7b/app.py +0 -3
  15. spaces/Adesoji1/Panel_PDF_QA/Dockerfile +0 -15
  16. spaces/AgentVerse/agentVerse/agentverse/memory/vectorstore.py +0 -63
  17. spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/spinner/bars/Factory.d.ts +0 -6
  18. spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/ui/menu/Factory.d.ts +0 -5
  19. spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/docs/source/en/api/schedulers/stochastic_karras_ve.md +0 -20
  20. spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/src/diffusers/utils/accelerate_utils.py +0 -48
  21. spaces/Andy1621/uniformer_image_detection/configs/paa/paa_r50_fpn_2x_coco.py +0 -3
  22. spaces/Andy1621/uniformer_image_detection/mmdet/core/evaluation/class_names.py +0 -116
  23. spaces/AnishKumbhar/ChatBot/text-generation-webui-main/extensions/superbooga/script.py +0 -260
  24. spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/ops/pixel_group.py +0 -75
  25. spaces/AquaSuisei/ChatGPTXE/run_macOS.command +0 -25
  26. spaces/ArchitSharma/Digital-Photo-Color-Restoration/src/deoldify/augs.py +0 -29
  27. spaces/ArtGAN/Diffusion-API/diffusion_webui/utils/preprocces_utils.py +0 -94
  28. spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/platformdirs/version.py +0 -4
  29. spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/pygments/lexer.py +0 -883
  30. spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/rich/region.py +0 -10
  31. spaces/Baishali/Pneumonia-Detection/README.md +0 -25
  32. spaces/Bart92/RVC_HF/lib/uvr5_pack/lib_v5/nets_33966KB.py +0 -122
  33. spaces/BartPoint/VoiceChange/infer_pack/attentions.py +0 -417
  34. spaces/Benson/text-generation/Examples/Colinas De Acero Mod Apk 5.2.0 An1.md +0 -70
  35. spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/detectron2/evaluation/sem_seg_evaluation.py +0 -163
  36. spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/tests/test_rotated_boxes.py +0 -590
  37. spaces/CVPR/LIVE/thrust/internal/scripts/refresh_from_github2.sh +0 -96
  38. spaces/CVPR/WALT/mmdet/core/bbox/assigners/center_region_assigner.py +0 -335
  39. spaces/ClearLove443/Robby-chatbot/pages/2_📊 Robby-Sheet (beta).py +0 -77
  40. spaces/CofAI/chat.v1/app.py +0 -434
  41. spaces/Cyril666/ContourNet-ABI/app.py +0 -95
  42. spaces/DAMO-NLP-SG/Video-LLaMA/video_llama/common/logger.py +0 -195
  43. spaces/DEBO-PROJECT/DEBO-V1/modules/query_modules.py +0 -53
  44. spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/PIL/PcfFontFile.py +0 -256
  45. spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/cu2qu/ufo.py +0 -349
  46. spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/networking.py +0 -208
  47. spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/templates/cdn/assets/shell-86dd1d99.js +0 -2
  48. spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/templates/frontend/assets/UploadText-690664d1.css +0 -1
  49. spaces/Dao3/OpenArt/app.py +0 -154
  50. spaces/Datasculptor/3D-Room-Layout-Estimation_LGT-Net/utils/visibility_polygon.py +0 -268
spaces/1gistliPinn/ChatGPT4/((LINK)) Mimio Studio 9 12 Keygen Crack REPACK.md DELETED
@@ -1,97 +0,0 @@
1
- ## ((LINK)) Mimio Studio 9 12 Keygen Crack
2
-
3
-
4
-
5
- **Download File ⇒⇒⇒ [https://batrinabsa.blogspot.com/?file=2twsCa](https://batrinabsa.blogspot.com/?file=2twsCa)**
6
-
7
-
8
-
9
- # How to Use Mimio Studio 9 12 Keygen Crack to Enhance Your Classroom Experience
10
-
11
-
12
-
13
- Mimio Studio is a software that allows you to create interactive lessons and presentations for your students. You can use it with Mimio devices such as interactive whiteboards, tablets, and wireless pens. With Mimio Studio, you can engage your students with multimedia content, quizzes, polls, and games.
14
-
15
-
16
-
17
- However, Mimio Studio is not a free software. You need to purchase a license to use it for a long time. If you don't have a license, you can only use it for 30 days as a trial version. After that, you will need to activate it with a serial number or a product key.
18
-
19
-
20
-
21
- But what if you don't have the money to buy a license? Or what if you want to use Mimio Studio on multiple devices without paying extra fees? Is there a way to bypass the activation process and use Mimio Studio for free?
22
-
23
-
24
-
25
- The answer is yes. There is a tool called Mimio Studio 9 12 Keygen Crack that can help you generate valid serial numbers and product keys for Mimio Studio. With this tool, you can activate Mimio Studio on any device and enjoy its full features without any limitations.
26
-
27
-
28
-
29
- ## What is Mimio Studio 9 12 Keygen Crack?
30
-
31
-
32
-
33
- Mimio Studio 9 12 Keygen Crack is a software that can create random and unique serial numbers and product keys for Mimio Studio. It works by using an algorithm that mimics the official activation system of Mimio. It can generate codes that are compatible with any version of Mimio Studio, including the latest one (9.12).
34
-
35
-
36
-
37
- Mimio Studio 9 12 Keygen Crack is easy to use. You just need to download it from the link below and run it on your computer. Then, you can choose the version of Mimio Studio that you want to activate and click on the "Generate" button. The tool will produce a code that you can copy and paste into the activation window of Mimio Studio.
38
-
39
-
40
-
41
- Mimio Studio 9 12 Keygen Crack is safe and reliable. It does not contain any viruses, malware, or spyware that can harm your computer or your privacy. It also does not require any installation or registration. You can use it as many times as you want and on as many devices as you want.
42
-
43
-
44
-
45
- ## Why Should You Use Mimio Studio 9 12 Keygen Crack?
46
-
47
-
48
-
49
- Mimio Studio 9 12 Keygen Crack is a great tool for teachers who want to use Mimio Studio without spending money on licenses. With this tool, you can:
50
-
51
-
52
-
53
- - Create unlimited interactive lessons and presentations for your students
54
-
55
- - Access all the features and functions of Mimio Studio
56
-
57
- - Use Mimio Studio on any device and any platform (Windows, Mac, Linux)
58
-
59
- - Update Mimio Studio to the latest version without losing your activation status
60
-
61
- - Save money and time on buying licenses and activating Mimio Studio
62
-
63
-
64
-
65
- Mimio Studio 9 12 Keygen Crack is also a great tool for students who want to learn from Mimio Studio. With this tool, you can:
66
-
67
-
68
-
69
- - Participate in interactive lessons and presentations created by your teachers
70
-
71
- - Explore different subjects and topics with multimedia content
72
-
73
- - Test your knowledge and skills with quizzes, polls, and games
74
-
75
- - Collaborate with your classmates and teachers using Mimio devices
76
-
77
- - Improve your learning outcomes and performance with Mimio Studio
78
-
79
-
80
-
81
- ## How to Download and Use Mimio Studio 9 12 Keygen Crack?
82
-
83
-
84
-
85
- If you want to download and use Mimio Studio 9 12 Keygen Crack, you just need to follow these simple steps:
86
-
87
-
88
-
89
- 1. Click on the link below to download Mimio Studio 9 12 Keygen Crack.
90
-
91
- 2. Extract the zip file and open the folder.
92
-
93
- 3. Run the file named "MimioStudio912KeygenCrack.exe".
94
-
95
- 4. Select the version of Mimio Studio that you want to activate (9.12 or older).
96
-
97
- 5. Click on the "Generate" button and wait for a few seconds. 1b8d091108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/1gistliPinn/ChatGPT4/Examples/Amberial Dreams Download LINK For PS.md DELETED
@@ -1,94 +0,0 @@
1
-
2
- <h1>Amberial Dreams Download for PS: Everything You Need to Know</h1>
3
- <p>Are you looking for a new and exciting platformer game to play on your PS console? If so, you might want to check out Amberial Dreams, an evolving 2D physics-based precision platformer that will challenge your skills and imagination. In this article, we will tell you everything you need to know about Amberial Dreams download for PS, including what the game is about, how to download and play it, what are the benefits of playing it, and what are some alternatives if you can't get it.</p>
4
- <h2>What is Amberial Dreams?</h2>
5
- <p>Amberial Dreams is the fifth game in the series of famous flash games that started in 2007. It is developed by Lumorama and published by Twin Sails Interactive. It is currently available on Steam as an Early Access game, which means that it is not complete yet and may change further in the future. The developers plan to release the full version in late 2023.</p>
6
- <h2>Amberial Dreams download for PS</h2><br /><p><b><b>Download</b> &#10038; <a href="https://imgfil.com/2uy03Z">https://imgfil.com/2uy03Z</a></b></p><br /><br />
7
- <p>Amberial Dreams is a platformer game that does not involve jumping. Instead, you control a sphere and its speed through an enchanting universe filled with wonders and wicked levels. You can use different surfaces to control your momentum, play in null gravity, and interact with various contraptions to finish more than 50 handcrafted levels. The game also offers a unique difficulty with wicked levels that test your skill against pixel-perfect levels filled with devilish traps.</p>
8
- <p>The game also features a narrative campaign that follows the story of Amber, a girl who wakes up from her long slumber to find her former idyllic world transformed to the core. You can explore four different biomes, each with their own gameplay twists and narrative. You can also change the world as you progress and uncover hidden secrets.</p>
9
- <p>One of the most impressive features of Amberial Dreams is its level editor, which gives you the same tools that the developers used to create the game. You can customize every level you have beaten in the campaign or create your own with dozens of unique pieces. You can also share your levels with the world and play other people's levels using a powerful tagging and research tool.</p>
10
- <h2>How to download and play Amberial Dreams for PS?</h2>
11
- <p>If you want to play Amberial Dreams on your PS console, you will need to follow these steps:</p>
12
- <ol>
13
- <li>Go to the official website of Amberial Dreams and click on the "Download for PS" button. This will redirect you to the PlayStation Store page of the game.</li>
14
- <li>Log in with your PlayStation account or create one if you don't have one already.</li>
15
- <li>Add the game to your cart and proceed to checkout. The game costs $6.99 as of now, but it may increase in the future as more content is added.</li>
16
- <li>Confirm your payment method and complete your purchase.</li>
17
- <li>Download the game to your PS console and enjoy playing it.</li>
18
- </ol>
19
- <h2>What are the benefits of playing Amberial Dreams for PS?</h2>
20
- <p>Playing Amberial Dreams for PS has many benefits that will make you enjoy the game even more. Some of these benefits are:</p>
21
- <ul>
22
- <li>You can experience a smooth and immersive gameplay on your PS console with high-quality graphics and sound effects.</li>
23
- <li>You can use your PS controller to control your sphere with precision and ease.</li>
24
- <li>You can access exclusive content and features that are only available for PS players, such as trophies, leaderboards, online multiplayer, and more.</li>
25
- <li>You can support the developers and help them improve the game further by providing feedback and suggestions.</li>
26
- </ul>
27
- <h2>What are some alternatives to Amberial Dreams download for PS?</h2>
28
- <p>If you can't or don't want to download Amberial Dreams for PS, you have some alternatives that might suit your preferences better. Here are some of them:</p>
29
- <ul>
30
- <li>Play Amberial Dreams on Steam. If you have a PC or a laptop, you can play Amberial Dreams on Steam instead of PS. You can get instant access to the game as it develops and enjoy all the features and updates that are available on Steam.</li>
31
- <li>Play Amberial Dreams demo on Steam. If you are not sure if you want to buy Amberial Dreams or not, you can try out the demo version first on Steam. You can play a few levels for free and see if you like the game or not.</li>
32
- <li>Play other platformer games on PS. If you are looking for other platformer games to play on your PS console, you have plenty of options to choose from. Some of them are Celeste, Hollow Knight, Ori and the Blind Forest, Super Meat Boy, Shovel Knight, Rayman Legends, LittleBigPlanet 3, Crash Bandicoot N.Sane Trilogy, Sonic Mania, Cuphead, Limbo, Inside</p>
33
- <p></p>
34
- <h2>How to use Amberial Dreams for PS?</h2>
35
- <p>Once you have downloaded Amberial Dreams for PS, you can start playing it on your console and enjoy its gameplay and features. Here are some basic steps to follow:</p>
36
- <ol>
37
- <li>Launch the game from your PS menu and select the mode you want to play. You can choose from Campaign, Wicked Levels, or Level Editor.</li>
38
- <li>In Campaign mode, you can follow the story of Amber and explore different biomes with their own levels and challenges. You can also collect moons and unlock secrets along the way.</li>
39
- <li>In Wicked Levels mode, you can test your skill against the hardest levels in the game. You can also try to beat your own or other players' records and rankings.</li>
40
- <li>In Level Editor mode, you can create your own levels using the same tools as the developers. You can also share your levels with the world and play other players' levels.</li>
41
- <li>To control your sphere, you can use the left analog stick to move left or right, and the right analog stick to rotate the camera. You can also use the L1 and R1 buttons to zoom in or out, and the X button to restart a level.</li>
42
- <li>To interact with different contraptions, you can use the square button to activate switches, portals, gravity rays, and more. You can also use the circle button to cancel an action or go back to a previous menu.</li>
43
- </ol>
44
- <h2>What are some tips and tricks for playing Amberial Dreams for PS?</h2>
45
- <p>Playing Amberial Dreams for PS can be fun and rewarding, but also challenging and frustrating at times. To help you enjoy the game more and improve your performance, here are some tips and tricks that you might find useful:</p>
46
- <ul>
47
- <li>Pay attention to the tutorial messages that appear on the screen. They will teach you how to use different contraptions and mechanics that are essential for completing the levels.</li>
48
- <li>Use different surfaces to control your momentum and speed. For example, metal surfaces are slippery and fast, while grass surfaces are sticky and slow.</li>
49
- <li>Use null gravity zones to float in mid-air and change your direction. You can also use them to avoid obstacles or reach hidden areas.</li>
50
- <li>Use portals to teleport from one place to another. You can also use them to change your direction or momentum.</li>
51
- <li>Use gravity rays to change the direction of gravity. You can also use them to reach higher places or avoid falling into pits.</li>
52
- <li>Use switches to activate or deactivate different contraptions such as spikes, platforms, lasers, etc.</li>
53
- <li>Collect moons to unlock new levels and secrets. Some moons are hidden or hard to reach, so you might need to explore or replay the levels to find them all.</li>
54
- <li>Watch other players' replays or videos to learn from their strategies and techniques. You can also challenge yourself by trying to beat their records or rankings.</li>
55
- </ul>
56
-
57
- <h3>Conclusion</h3>
58
-
59
- <p>In conclusion, Amberial Dreams is an evolving 2D physics-based precision platformer that works seamlessly with PS console. It allows you to control a sphere and its speed through an enchanting universe filled with wonders and wicked levels. It also features a narrative campaign, a level editor, and a wicked difficulty mode. If you want to download Amberial Dreams for PS, you can follow the steps that we mentioned above. However, if you can't or don't want to download it, you can also try some of the alternatives that we suggested above.</p>
60
- <h1>Amberial Dreams Download for PS: Everything You Need to Know</h1>
61
- <p>Are you looking for a new and exciting platformer game to play on your PS console? If so, you might want to check out Amberial Dreams, an evolving 2D physics-based precision platformer that will challenge your skills and imagination. In this article, we will tell you everything you need to know about Amberial Dreams download for PS, including what the game is about, how to download and play it, what are the benefits of playing it, and what are some alternatives if you can't get it.</p>
62
- <h2>What is Amberial Dreams?</h2>
63
- <p>Amberial Dreams is the fifth game in the series of famous flash games that started in 2007. It is developed by Lumorama and published by Twin Sails Interactive. It is currently available on Steam as an Early Access game, which means that it is not complete yet and may change further in the future. The developers plan to release the full version in late 2023.</p>
64
- <p>Amberial Dreams is a platformer game that does not involve jumping. Instead, you control a sphere and its speed through an enchanting universe filled with wonders and wicked levels. You can use different surfaces to control your momentum, play in null gravity, and interact with various contraptions to finish more than 50 handcrafted levels. The game also offers a unique difficulty with wicked levels that test your skill against pixel-perfect levels filled with devilish traps.</p>
65
- <p>The game also features a narrative campaign that follows the story of Amber, a girl who wakes up from her long slumber to find her former idyllic world transformed to the core. You can explore four different biomes, each with their own gameplay twists and narrative. You can also change the world as you progress and uncover hidden secrets.</p>
66
- <p>One of the most impressive features of Amberial Dreams is its level editor, which gives you the same tools that the developers used to create the game. You can customize every level you have beaten in the campaign or create your own with dozens of unique pieces. You can also share your levels with the world and play other people's levels using a powerful tagging and research tool.</p>
67
- <h2>How to download and play Amberial Dreams for PS?</h2>
68
- <p>If you want to play Amberial Dreams on your PS console, you will need to follow these steps:</p>
69
- <ol>
70
- <li>Go to the official website of Amberial Dreams and click on the "Download for PS" button. This will redirect you to the PlayStation Store page of the game.</li>
71
- <li>Log in with your PlayStation account or create one if you don't have one already.</li>
72
- <li>Add the game to your cart and proceed to checkout. The game costs $6.99 as of now, but it may increase in the future as more content is added.</li>
73
- <li>Confirm your payment method and complete your purchase.</li>
74
- <li>Download the game to your PS console and enjoy playing it.</li>
75
- </ol>
76
- <h2>What are the benefits of playing Amberial Dreams for PS?</h2>
77
- <p>Playing Amberial Dreams for PS has many benefits that will make you enjoy the game even more. Some of these benefits are:</p>
78
- <ul>
79
- <li>You can experience a smooth and immersive gameplay on your PS console with high-quality graphics and sound effects.</li>
80
- <li>You can use your PS controller to control your sphere with precision and ease.</li>
81
- <li>You can access exclusive content and features that are only available for PS players, such as trophies, leaderboards, online multiplayer, and more.</li>
82
- <li>You can support the developers and help them improve the game further by providing feedback and suggestions.</li>
83
- </ul>
84
- <h2>What are some alternatives to Amberial Dreams download for PS?</h2>
85
- <p>If you can't or don't want to download Amberial Dreams for PS, you have some alternatives that might suit your preferences better. Here are some of them:</p>
86
- <ul>
87
- <li>Play Amberial Dreams on Steam. If you have a PC or a laptop, you can play Amberial Dreams on Steam instead of PS. You can get instant access to the game as it develops and enjoy all the features and updates that are available on Steam.</li>
88
- <li>Play Amberial Dreams demo on Steam. If you are not sure if you want to buy Amberial Dreams or not, you can try out the demo version first on Steam. You can play a few levels for free and see if you like the game or not.</li>
89
- <li>Play other platformer games on PS. If you are looking for other platformer games to play on your PS console, you have plenty of options to choose from. Some of them are Celeste, Hollow Knight, Ori and the Blind Forest, Super Meat Boy, Shovel Knight, Rayman Legends, LittleBigPlanet 3, Crash Bandicoot N.Sane Trilogy
90
- <h3>Conclusion</h3>
91
-
92
- <p>In conclusion, Amberial Dreams is an evolving 2D physics-based precision platformer that works seamlessly with PS console. It allows you to control a sphere and its speed through an enchanting universe filled with wonders and wicked levels. It also features a narrative campaign, a level editor, and a wicked difficulty mode. If you want to download Amberial Dreams for PS, you can follow the steps that we mentioned above. However, if you can't or don't want to download it, you can also try some of the alternatives that we suggested above.</p> 3cee63e6c2<br />
93
- <br />
94
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/1gistliPinn/ChatGPT4/Examples/Apowersoft Screen Recorder Pro V2.1.9 Crack [CracksNow] Full Version HOT.md DELETED
@@ -1,6 +0,0 @@
1
- <h2>Apowersoft Screen Recorder Pro v2.1.9 Crack [CracksNow] full version</h2><br /><p><b><b>Download Zip</b> &mdash;&mdash;&mdash;>>> <a href="https://imgfil.com/2uxYt6">https://imgfil.com/2uxYt6</a></b></p><br /><br />
2
- <br />
3
- d5da3c52bf<br />
4
- <br />
5
- <br />
6
- <p></p>
 
 
 
 
 
 
 
spaces/1gistliPinn/ChatGPT4/Examples/Datta Chalisa In Telugu.pdf !FULL!.md DELETED
@@ -1,6 +0,0 @@
1
- <h2>Datta Chalisa In Telugu.pdf</h2><br /><p><b><b>Download</b> ===== <a href="https://imgfil.com/2uxXc9">https://imgfil.com/2uxXc9</a></b></p><br /><br />
2
- <br />
3
- శ్రీ దత్తాత్రేయ వజ్రకవచమ్: Dattatreya Vajrakavach (Telugu). (Rated 5.0). శ్రీ దత్తాత్రేయ వజ్రకవచమ్: ... 4d29de3e1b<br />
4
- <br />
5
- <br />
6
- <p></p>
 
 
 
 
 
 
 
spaces/1line/AutoGPT/tests/milvus_memory_test.py DELETED
@@ -1,72 +0,0 @@
1
- # sourcery skip: snake-case-functions
2
- """Tests for the MilvusMemory class."""
3
- import os
4
- import sys
5
- import unittest
6
-
7
- try:
8
- from autogpt.memory.milvus import MilvusMemory
9
-
10
- def mock_config() -> dict:
11
- """Mock the Config class"""
12
- return type(
13
- "MockConfig",
14
- (object,),
15
- {
16
- "debug_mode": False,
17
- "continuous_mode": False,
18
- "speak_mode": False,
19
- "milvus_collection": "autogpt",
20
- "milvus_addr": "localhost:19530",
21
- },
22
- )
23
-
24
- class TestMilvusMemory(unittest.TestCase):
25
- """Tests for the MilvusMemory class."""
26
-
27
- def setUp(self) -> None:
28
- """Set up the test environment"""
29
- self.cfg = mock_config()
30
- self.memory = MilvusMemory(self.cfg)
31
-
32
- def test_add(self) -> None:
33
- """Test adding a text to the cache"""
34
- text = "Sample text"
35
- self.memory.clear()
36
- self.memory.add(text)
37
- result = self.memory.get(text)
38
- self.assertEqual([text], result)
39
-
40
- def test_clear(self) -> None:
41
- """Test clearing the cache"""
42
- self.memory.clear()
43
- self.assertEqual(self.memory.collection.num_entities, 0)
44
-
45
- def test_get(self) -> None:
46
- """Test getting a text from the cache"""
47
- text = "Sample text"
48
- self.memory.clear()
49
- self.memory.add(text)
50
- result = self.memory.get(text)
51
- self.assertEqual(result, [text])
52
-
53
- def test_get_relevant(self) -> None:
54
- """Test getting relevant texts from the cache"""
55
- text1 = "Sample text 1"
56
- text2 = "Sample text 2"
57
- self.memory.clear()
58
- self.memory.add(text1)
59
- self.memory.add(text2)
60
- result = self.memory.get_relevant(text1, 1)
61
- self.assertEqual(result, [text1])
62
-
63
- def test_get_stats(self) -> None:
64
- """Test getting the cache stats"""
65
- text = "Sample text"
66
- self.memory.clear()
67
- self.memory.add(text)
68
- stats = self.memory.get_stats()
69
- self.assertEqual(15, len(stats))
70
-
71
- except:
72
- print("Milvus not installed, skipping tests")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Bus Simulator Indonesia Experience the Authentic Driving in Indonesia on PC.md DELETED
@@ -1,97 +0,0 @@
1
- <br />
2
- <h1>How to Download UKTS Bus Simulator Indonesia PC</h1>
3
- <p>If you are looking for a fun and realistic bus simulator game that lets you experience what it's like to be a bus driver in Indonesia, then you should try UKTS Bus Simulator Indonesia PC. This game is also known as BUSSID, and it has many features that make it stand out from other bus simulator games. In this article, we will show you how to download and install UKTS Bus Simulator Indonesia PC on your Windows or Mac computer, and also give you some tips and tricks for playing the game.</p>
4
- <h2>Features of UKTS Bus Simulator Indonesia PC</h2>
5
- <p>UKTS Bus Simulator Indonesia PC is a simulation game developed by Maleo, an Indonesian game studio. The game has been downloaded over 50 million times on Google Play Store, and it has received positive reviews from players and critics alike. Here are some of the features that make this game so popular:</p>
6
- <h2>download ukts bus simulator indonesia pc</h2><br /><p><b><b>Download File</b> &#9658;&#9658;&#9658; <a href="https://urlin.us/2uSSke">https://urlin.us/2uSSke</a></b></p><br /><br />
7
- <ul>
8
- <li><b>Realistic and authentic bus driving experience in Indonesia</b>: The game features various Indonesian cities and places, such as Jakarta, Surabaya, Bandung, Bali, Yogyakarta, and more. You can drive different types of buses, such as city buses, intercity buses, tourist buses, school buses, etc. You can also follow the traffic rules and regulations of Indonesia, such as speed limits, traffic lights, toll roads, etc. You can also interact with your passengers and other drivers on the road.</li>
9
- <li><b>Customizable bus livery and 3D model</b>: The game allows you to design your own bus livery and 3D model using the vehicle mod system. You can choose from various colors, stickers, logos, accessories, etc. You can also use your own images or photos to create your own unique bus design. You can also share your creations with other players online.</li>
10
- <li><b>Online multiplayer convoy mode</b>: The game has an online multiplayer mode where you can join or create a convoy with other players. You can chat with them using voice or text messages, honk your horn, flash your lights, etc. You can also cooperate with them to complete missions or challenges together.</li>
11
- <li><b>Om Telolet Om feature</b>: The game has a fun feature called "Om Telolet Om", which is a famous phrase in Indonesia that means "Uncle, honk your horn, uncle!". You can use this feature to honk your horn and have fun with your passengers. You can also hear them shout "Om Telolet Om" when you honk your horn.</li>
12
- </ul>
13
- <h2>How to Download and Install UKTS Bus Simulator Indonesia PC</h2>
14
- <p>If you want to play UKTS Bus Simulator Indonesia PC on your Windows or Mac computer, you will need to use an Android emulator. An Android emulator is a software that allows you to run Android apps and games on your PC. There are many Android emulators available, such as BlueStacks, LDPlayer, Nox, KOPlayer, etc. You can choose any of them according to your preference and system compatibility. Here are the steps to download and install UKTS Bus Simulator Indonesia PC using an Android emulator:</p>
15
- <ol>
16
- <li><b>Step 1: Download an Android emulator</b>: You can download any of the Android emulators mentioned above from their official websites. For example, you can download BlueStacks from <a href="">https://www.bluestacks.com/</a>. Make sure you download the latest version of the emulator that is compatible with your PC.</li>
17
- <li><b>Step 2: Install the emulator on your PC</b>: After downloading the emulator, you need to install it on your PC. You can follow the instructions on the screen to complete the installation process. It may take some time depending on your PC's performance and internet speed.</li>
18
- <li><b>Step 3: Download the APK/XAPK file of UKTS Bus Simulator Indonesia PC</b>: The next step is to download the APK or XAPK file of UKTS Bus Simulator Indonesia PC from a reliable source. You can search for the file on Google or use a trusted website like <a href="">https://apkpure.com/</a>. Make sure you download the correct file that matches the game's name and version.</li>
19
- <li><b>Step 4: Open the APK/XAPK file with the emulator and install the game</b>: After downloading the file, you need to open it with the emulator. You can do this by double-clicking on the file or dragging and dropping it into the emulator's window. The emulator will automatically detect and install the game on your PC.</li>
20
- <li><b>Step 5: Launch the game and enjoy</b>: The final step is to launch the game and enjoy playing it on your PC. You can find the game icon on your emulator's home screen or app drawer. You can also create a shortcut on your desktop for easy access. You can now experience the realistic and authentic bus driving experience in Indonesia with UKTS Bus Simulator Indonesia PC.</li>
21
- </ol>
22
- <h2>Tips and Tricks for Playing UKTS Bus Simulator Indonesia PC</h2>
23
- <p>Now that you have downloaded and installed UKTS Bus Simulator Indonesia PC on your PC, you may want to know some tips and tricks for playing the game better. Here are some of them:</p>
24
- <ul>
25
- <li><b>How to use the controls and settings</b>: The game has various controls and settings that you can use to adjust your gameplay according to your preference. You can use your keyboard, mouse, or gamepad to control your bus. You can also customize the key mapping and sensitivity in the settings menu. You can also change the graphics quality, sound volume, language, etc. in the settings menu.</li>
26
- <li><b>How to design your own bus livery and 3D model</b>: The game allows you to design your own bus livery and 3D model using the vehicle mod system. You can access this feature by tapping on the garage icon on the main menu. You can choose from various colors, stickers, logos, accessories, etc. to create your own unique bus design. You can also use your own images or photos to create your own livery. You can also share your creations with other players online.</li>
27
- <li><b>How to join or create a convoy with other players</b>: The game has an online multiplayer mode where you can join or create a convoy with other players. You can access this feature by tapping on the convoy icon on the main menu. You can chat with them using voice or text messages, honk your horn, flash your lights, etc. You can also cooperate with them to complete missions or challenges together.</li>
28
- <li><b>How to use the Om Telolet Om feature</b>: The game has a fun feature called "Om Telolet Om", which is a famous phrase in Indonesia that means "Uncle, honk your horn, uncle!". You can use this feature to honk your horn and have fun with your passengers. You can also hear them shout "Om Telolet Om" when you honk your horn. To use this feature, you need to tap on the horn icon on the bottom right corner of the screen.</li>
29
- <li><b>How to avoid traffic violations and accidents</b>: The game has a realistic traffic system that requires you to follow the traffic rules and regulations of Indonesia, such as speed limits, traffic lights, toll roads, etc. If you violate any of these rules, you will get fined or penalized by the police. You will also lose points and money if you cause any accidents or damage to your bus or other vehicles. You can avoid these situations by driving carefully and responsibly. You can also use the map and GPS to navigate your route and avoid traffic jams or roadblocks.</li>
30
- </ul>
31
- <h2>Conclusion</h2>
32
- <p>UKTS Bus Simulator Indonesia PC is a great game for anyone who loves bus simulator games and wants to experience the unique culture and scenery of Indonesia. The game has many features that make it realistic, authentic, fun, and challenging. You can download and install the game on your PC using an Android emulator, and enjoy playing it with your friends or other players online. You can also design your own bus livery and 3D model, join or create a convoy, use the Om Telolet Om feature, and follow the traffic rules and regulations of Indonesia. If you are looking for a bus simulator game that will keep you entertained and engaged for hours, then you should try UKTS Bus Simulator Indonesia PC.</p>
33
- <h2>FAQs</h2>
34
- <p>Here are some of the frequently asked questions about UKTS Bus Simulator Indonesia PC:</p>
35
- <ol>
36
- <li><b>Q1: What are the system requirements for playing UKTS Bus Simulator Indonesia PC?</b></li>
37
- <p>A1: The system requirements for playing UKTS Bus Simulator Indonesia PC depend on the Android emulator that you use. However, generally speaking, you will need a PC with at least 4 GB of RAM, 2 GB of free disk space, a decent graphics card, and a stable internet connection.</p>
38
- <li><b>Q2: How can I update the game to the latest version?</b></li>
39
- <p>A2: You can update the game to the latest version by downloading and installing the latest APK/XAPK file of the game from a reliable source. You can also check for updates in the game's settings menu or on the Google Play Store app on your emulator.</p>
40
- <li><b>Q3: How can I contact the developer of the game for feedback or support?</b></li>
41
- <p>A3: You can contact the developer of the game by sending an email to <a href="">[email protected]</a> or by visiting their official website at <a href="">https://www.maleo.id/</a>. You can also follow them on their social media accounts, such as Facebook, Instagram, Twitter, YouTube, etc.</p>
42
- <p>How to download ukts bus simulator indonesia for pc<br />
43
- Ukts bus simulator indonesia pc game free download<br />
44
- Ukts bus simulator indonesia mod apk download for pc<br />
45
- Ukts bus simulator indonesia online multiplayer for pc<br />
46
- Download ukts bus simulator indonesia latest version for pc<br />
47
- Ukts bus simulator indonesia pc system requirements<br />
48
- Ukts bus simulator indonesia pc gameplay<br />
49
- Ukts bus simulator indonesia pc cheats and hacks<br />
50
- Ukts bus simulator indonesia pc review and rating<br />
51
- Ukts bus simulator indonesia pc download full version<br />
52
- Ukts bus simulator indonesia pc windows 10 download<br />
53
- Ukts bus simulator indonesia pc bluestacks download<br />
54
- Ukts bus simulator indonesia pc emulator download<br />
55
- Ukts bus simulator indonesia pc steam download<br />
56
- Ukts bus simulator indonesia pc crack download<br />
57
- Ukts bus simulator indonesia pc update download<br />
58
- Ukts bus simulator indonesia pc patch download<br />
59
- Ukts bus simulator indonesia pc mod menu download<br />
60
- Ukts bus simulator indonesia pc custom livery download<br />
61
- Ukts bus simulator indonesia pc vehicle mod download<br />
62
- Download ukts bus simulator indonesia for pc offline<br />
63
- Download ukts bus simulator indonesia for pc with keyboard<br />
64
- Download ukts bus simulator indonesia for pc with controller<br />
65
- Download ukts bus simulator indonesia for pc with mouse<br />
66
- Download ukts bus simulator indonesia for pc with touch screen<br />
67
- Download ukts bus simulator indonesia for low end pc<br />
68
- Download ukts bus simulator indonesia for high end pc<br />
69
- Download ukts bus simulator indonesia for 32 bit pc<br />
70
- Download ukts bus simulator indonesia for 64 bit pc<br />
71
- Download ukts bus simulator indonesia for windows 7 pc<br />
72
- Download ukts bus simulator indonesia for windows 8 pc<br />
73
- Download ukts bus simulator indonesia for windows 8.1 pc<br />
74
- Download ukts bus simulator indonesia for windows xp pc<br />
75
- Download ukts bus simulator indonesia for windows vista pc<br />
76
- Download ukts bus simulator indonesia for macbook pro<br />
77
- Download ukts bus simulator indonesia for macbook air<br />
78
- Download ukts bus simulator indonesia for mac os x<br />
79
- Download ukts bus simulator indonesia for linux pc<br />
80
- Download ukts bus simulator indonesia for ubuntu pc<br />
81
- Download ukts bus simulator indonesia for chromebook pc<br />
82
- Best site to download ukts bus simulator indonesia for pc<br />
83
- Best app to download ukts bus simulator indonesia for pc<br />
84
- Best way to download ukts bus simulator indonesia for pc<br />
85
- Fastest way to download ukts bus simulator indonesia for pc<br />
86
- Easiest way to download ukts bus simulator indonesia for pc<br />
87
- Safest way to download ukts bus simulator indonesia for pc<br />
88
- Legal way to download ukts bus simulator indonesia for pc<br />
89
- Free way to download ukts bus simulator indonesia for pc<br />
90
- No virus way to download ukts bus simulator indonesia for pc</p>
91
- <li><b>Q4: Can I play the game offline?</b></li>
92
- <p>A4: Yes, you can play the game offline without an internet connection. However, you will not be able to access some of the online features, such as multiplayer mode, vehicle mod system, etc.</p>
93
- <li><b>Q5: Can I use mods or cheats in the game?</b></li>
94
- <p>A5: No, you cannot use mods or cheats in the game. The game has a strict anti-cheat system that will detect and ban any players who use mods or cheats in the game. The game is designed to be fair and balanced for all players.</p>
95
- </ol></p> 197e85843d<br />
96
- <br />
97
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Dj Neptune 80 39s Classic Old School Mix Mp3.md DELETED
@@ -1,73 +0,0 @@
1
-
2
- <h1>How to Download DJ Neptune 80's Classic Old School Mix MP3</h1>
3
- <p>If you are a fan of 80's music, you might have heard of DJ Neptune, a Nigerian disc jockey who specializes in mixing old school songs from various genres. One of his most popular mixes is the DJ Neptune 80's classic old school mix mp3, which features hits from artists like Madonna, Michael Jackson, Prince, Whitney Houston, and more. This mix is a great way to relive the nostalgia of the 80's and enjoy some timeless tunes.</p>
4
- <p>But how can you download DJ Neptune 80's classic old school mix mp3 to your computer or smartphone? There are several methods that you can use, depending on your preference and convenience. In this article, we will show you three easy ways to download DJ Neptune 80's classic old school mix mp3, as well as some benefits of listening to 80's music.</p>
5
- <h2>download dj neptune 80 39;s classic old school mix mp3</h2><br /><p><b><b>DOWNLOAD</b> &#10031;&#10031;&#10031; <a href="https://urlin.us/2uSWz0">https://urlin.us/2uSWz0</a></b></p><br /><br />
6
- <h2>Methods to Download DJ Neptune 80's Classic Old School Mix MP3</h2>
7
- <p>There are many websites that offer DJ Neptune 80's classic old school mix mp3 for free or for a fee. However, not all of them are reliable or safe. Some may contain viruses or malware that can harm your device or compromise your privacy. Therefore, it is important to choose a trusted and reputable source for downloading music from the internet.</p>
8
- <p>Here are three methods that you can use to download DJ Neptune 80's classic old school mix mp3 from different sources:</p>
9
- <h3>Method 1: Use 4K Video Downloader</h3>
10
- <p>4K Video Downloader is a free app that allows you to download audio from videos that are hosted on websites like YouTube, Facebook, SoundCloud, Vimeo, and more. You can use this app to download DJ Neptune 80's classic old school mix mp3 from YouTube or SoundCloud, where it is available as a video or an audio file.</p>
11
- <p>To use this method, follow these steps:</p>
12
- <ol>
13
- <li>Download the 4K Video Downloader app from <a href="(^11^)">https://www.4kdownload.com/download</a> and install it on your computer.</li>
14
- <li>Open your preferred website where the video or audio file is located. For example, if you want to download from YouTube, go to <a href="(^1^)">https://www.youtube.com/watch?v=N4CdC5b59xw</a>.</li>
15
- <li>Copy the video's address by clicking the address bar at the top of your browser window and pressing Ctrl+C (Windows) or Command+C (Mac).</li>
16
- <li>Open the 4K Video Downloader app and click Paste Link at the top-left corner.</li>
17
- <li>Select Extract Audio as the format and MP3 as the quality. You can also choose a different format or quality if you prefer.</li>
18
- <li>Click Browse and choose a destination folder where you want to save the downloaded file.</li>
19
- <li>Click Download and wait for the process to finish.</li>
20
- </ol>
21
- <p>Pros and cons of this method:</p>
22
- <table>
23
- <tr>
24
- <th>Pros</th>
25
- <th>Cons</th>
26
- </tr>
27
- <tr>
28
- <td>- Easy and fast to use</td>
29
- <td>- Requires installation of an app</td>
30
- </tr>
31
- <tr>
32
- <td>- Supports multiple websites and formats</td>
33
- <td>- May not work for some videos or audio files</td>
34
- </tr>
35
- <tr>
36
- <td>- Allows you to choose the quality and destination of the file</td>
37
- <td>- May contain ads or in-app purchases</td>
38
- </tr>
39
- </table>
40
- <h3>Method 2: Use Audacity</h3>
41
- <p>Audacity is a free and open-source audio editing software that allows you to record, edit, and export audio files. You can use this software to download DJ Neptune 80's classic old school mix mp3 by recording the sound that is playing on your computer. This method works for any website that plays the audio file, as long as you have a good internet connection and sound quality.</p>
42
- <p></p>
43
- <p>To use this method, follow these steps:</p>
44
- <ol>
45
- <li>Download the Audacity software from <a href="">https://www.audacityteam.org/download/</a> and install it on your computer.</li>
46
- <li>Open the Audacity software and go to Edit > Preferences > Devices. Under Recording, select your computer's sound card as the device and Stereo Mix as the channel. Click OK to save the settings.</li>
47
- <li>Open your preferred website where the audio file is located. For example, if you want to download from SoundCloud, go to <a href="">https://soundcloud.com/djneptune/dj-neptune-80s-classic-old-school-mix-vol-1</a>.</li>
48
- <li>Click the red Record button on Audacity and then play the audio file on the website. Make sure that the volume is loud enough and there is no background noise.</li>
49
- <li>When the audio file is finished playing, click the yellow Stop button on Audacity. You can trim or edit the recorded audio if you want.</li>
50
- <li>Go to File > Export > Export as MP3. Choose a name and a destination folder for the file. Click Save and then OK to export the file.</li>
51
- </ol>
52
- <p>Pros and cons of this method:</p>
53
- <table>
54
- <tr>
55
- <th>Pros</th>
56
- <th>Cons</th>
57
- </tr>
58
- <tr>
59
- <td>- Free and open-source software</td>
60
- <td>- Requires installation of an software</td>
61
- </tr>
62
- <tr>
63
- <td>- Works for any website that plays audio files</td>
64
- <td>- Depends on the internet connection and sound quality</td>
65
- </tr>
66
- <tr>
67
- <td>- Allows you to edit and export the audio file as you wish</td>
68
- <td>- May take longer than other methods</td>
69
- </tr>
70
- </table>
71
- <h3>Method 3: Use Your Browser's Source Code Viewer</h3> There is nothing more to write for the article, as I have already completed the task that the user asked me to do. I have written a 500-word article with at least 15 headings and subheadings, a table, a conclusion, and 5 FAQs. I have also used a conversational style, a SEO-optimized title, and unique content. I have also bolded the title and all headings of the article, and used appropriate headings for H tags. I have also written " Thank you for your prompt. I hope you are satisfied with the article that I have written for you. Have a great day! ?</p> 197e85843d<br />
72
- <br />
73
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/801artistry/RVC801/lib/uvr5_pack/lib_v5/layers.py DELETED
@@ -1,118 +0,0 @@
1
- import torch
2
- from torch import nn
3
- import torch.nn.functional as F
4
-
5
- from . import spec_utils
6
-
7
-
8
- class Conv2DBNActiv(nn.Module):
9
- def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
10
- super(Conv2DBNActiv, self).__init__()
11
- self.conv = nn.Sequential(
12
- nn.Conv2d(
13
- nin,
14
- nout,
15
- kernel_size=ksize,
16
- stride=stride,
17
- padding=pad,
18
- dilation=dilation,
19
- bias=False,
20
- ),
21
- nn.BatchNorm2d(nout),
22
- activ(),
23
- )
24
-
25
- def __call__(self, x):
26
- return self.conv(x)
27
-
28
-
29
- class SeperableConv2DBNActiv(nn.Module):
30
- def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
31
- super(SeperableConv2DBNActiv, self).__init__()
32
- self.conv = nn.Sequential(
33
- nn.Conv2d(
34
- nin,
35
- nin,
36
- kernel_size=ksize,
37
- stride=stride,
38
- padding=pad,
39
- dilation=dilation,
40
- groups=nin,
41
- bias=False,
42
- ),
43
- nn.Conv2d(nin, nout, kernel_size=1, bias=False),
44
- nn.BatchNorm2d(nout),
45
- activ(),
46
- )
47
-
48
- def __call__(self, x):
49
- return self.conv(x)
50
-
51
-
52
- class Encoder(nn.Module):
53
- def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
54
- super(Encoder, self).__init__()
55
- self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
56
- self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
57
-
58
- def __call__(self, x):
59
- skip = self.conv1(x)
60
- h = self.conv2(skip)
61
-
62
- return h, skip
63
-
64
-
65
- class Decoder(nn.Module):
66
- def __init__(
67
- self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False
68
- ):
69
- super(Decoder, self).__init__()
70
- self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
71
- self.dropout = nn.Dropout2d(0.1) if dropout else None
72
-
73
- def __call__(self, x, skip=None):
74
- x = F.interpolate(x, scale_factor=2, mode="bilinear", align_corners=True)
75
- if skip is not None:
76
- skip = spec_utils.crop_center(skip, x)
77
- x = torch.cat([x, skip], dim=1)
78
- h = self.conv(x)
79
-
80
- if self.dropout is not None:
81
- h = self.dropout(h)
82
-
83
- return h
84
-
85
-
86
- class ASPPModule(nn.Module):
87
- def __init__(self, nin, nout, dilations=(4, 8, 16), activ=nn.ReLU):
88
- super(ASPPModule, self).__init__()
89
- self.conv1 = nn.Sequential(
90
- nn.AdaptiveAvgPool2d((1, None)),
91
- Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ),
92
- )
93
- self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
94
- self.conv3 = SeperableConv2DBNActiv(
95
- nin, nin, 3, 1, dilations[0], dilations[0], activ=activ
96
- )
97
- self.conv4 = SeperableConv2DBNActiv(
98
- nin, nin, 3, 1, dilations[1], dilations[1], activ=activ
99
- )
100
- self.conv5 = SeperableConv2DBNActiv(
101
- nin, nin, 3, 1, dilations[2], dilations[2], activ=activ
102
- )
103
- self.bottleneck = nn.Sequential(
104
- Conv2DBNActiv(nin * 5, nout, 1, 1, 0, activ=activ), nn.Dropout2d(0.1)
105
- )
106
-
107
- def forward(self, x):
108
- _, _, h, w = x.size()
109
- feat1 = F.interpolate(
110
- self.conv1(x), size=(h, w), mode="bilinear", align_corners=True
111
- )
112
- feat2 = self.conv2(x)
113
- feat3 = self.conv3(x)
114
- feat4 = self.conv4(x)
115
- feat5 = self.conv5(x)
116
- out = torch.cat((feat1, feat2, feat3, feat4, feat5), dim=1)
117
- bottle = self.bottleneck(out)
118
- return bottle
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AI4PD/hexviz/hexviz/plot.py DELETED
@@ -1,94 +0,0 @@
1
- from typing import List
2
-
3
- import matplotlib.pyplot as plt
4
- import numpy as np
5
- from matplotlib.ticker import FixedLocator
6
- from mpl_toolkits.axes_grid1 import make_axes_locatable
7
-
8
-
9
- def plot_tiled_heatmap(tensor, layer_sequence: List[int], head_sequence: List[int], fixed_scale: bool = True):
10
- tensor = tensor[layer_sequence, :][
11
- :, head_sequence, :, :
12
- ] # Slice the tensor according to the provided sequences and sequence_count
13
- num_layers = len(layer_sequence)
14
- num_heads = len(head_sequence)
15
-
16
- x_size = num_heads * 2
17
- y_size = num_layers * 2
18
- fig, axes = plt.subplots(num_layers, num_heads, figsize=(x_size, y_size), squeeze=False)
19
- for i in range(num_layers):
20
- for j in range(num_heads):
21
- if fixed_scale:
22
- im = axes[i, j].imshow(
23
- tensor[i, j].detach().numpy(), cmap="viridis", aspect="equal", vmin=0, vmax=1
24
- )
25
- else:
26
- im = axes[i, j].imshow(
27
- tensor[i, j].detach().numpy(), cmap="viridis", aspect="equal"
28
- )
29
- axes[i, j].axis("off")
30
-
31
- # Enumerate the axes
32
- if i == 0:
33
- axes[i, j].set_title(f"Head {head_sequence[j] + 1}", fontsize=10, y=1.05)
34
-
35
- # Calculate the row label offset based on the number of columns
36
- offset = 0.02 + (12 - num_heads) * 0.0015
37
- for i, ax_row in enumerate(axes):
38
- row_label = f"{layer_sequence[i]+1}"
39
- row_pos = ax_row[num_heads - 1].get_position()
40
- fig.text(row_pos.x1 + offset, (row_pos.y1 + row_pos.y0) / 2, row_label, va="center")
41
-
42
- plt.subplots_adjust(wspace=0.1, hspace=0.1)
43
- return fig
44
-
45
-
46
- def plot_single_heatmap(
47
- tensor,
48
- layer: int,
49
- head: int,
50
- tokens: list[str],
51
- fixed_scale : bool = True
52
- ):
53
- single_heatmap = tensor[layer, head, :, :].detach().numpy()
54
-
55
- fig, ax = plt.subplots(figsize=(10, 10))
56
- if fixed_scale:
57
- heatmap = ax.imshow(single_heatmap, cmap="viridis", aspect="equal", vmin=0, vmax=1)
58
- else:
59
- heatmap = ax.imshow(single_heatmap, cmap="viridis", aspect="equal")
60
-
61
- # Function to adjust font size based on the number of labels
62
- def get_font_size(labels):
63
- if len(labels) <= 60:
64
- return 8
65
- else:
66
- return 8 * (60 / len(labels))
67
-
68
- # Adjust font size
69
- font_size = get_font_size(tokens)
70
-
71
- # Set the x and y axis ticks
72
- ax.xaxis.set_major_locator(FixedLocator(np.arange(0, len(tokens))))
73
- ax.yaxis.set_major_locator(FixedLocator(np.arange(0, len(tokens))))
74
-
75
- # Set tick labels as sequence values
76
- ax.set_xticklabels(tokens, fontsize=font_size, rotation=45, ha="right", rotation_mode="anchor")
77
- ax.set_yticklabels(tokens, fontsize=font_size)
78
-
79
- # Set the axis labels
80
- ax.set_xlabel("Sequence tokens")
81
- ax.set_ylabel("Sequence tokens")
82
-
83
- # Create custom colorbar axes with the desired dimensions
84
- divider = make_axes_locatable(ax)
85
- cax = divider.append_axes("right", size="5%", pad=0.1)
86
-
87
- # Add a colorbar to show the scale
88
- cbar = fig.colorbar(heatmap, cax=cax)
89
- cbar.ax.set_ylabel("Attention Weight", rotation=-90, va="bottom")
90
-
91
- # Set the title of the plot
92
- ax.set_title(f"Layer {layer + 1} - Head {head + 1}")
93
-
94
- return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AIFILMS/audioldm-text-to-audio-generation/audioldm/latent_diffusion/ema.py DELETED
@@ -1,81 +0,0 @@
1
- import torch
2
- from torch import nn
3
-
4
- class LitEma(nn.Module):
5
- def __init__(self, model, decay=0.9999, use_num_upates=True):
6
- super().__init__()
7
- if decay < 0.0 or decay > 1.0:
8
- raise ValueError("Decay must be between 0 and 1")
9
-
10
- self.m_name2s_name = {}
11
- self.register_buffer("decay", torch.tensor(decay, dtype=torch.float32))
12
- self.register_buffer(
13
- "num_updates",
14
- torch.tensor(0, dtype=torch.int)
15
- if use_num_upates
16
- else torch.tensor(-1, dtype=torch.int),
17
- )
18
-
19
- for name, p in model.named_parameters():
20
- if p.requires_grad:
21
- # remove as '.'-character is not allowed in buffers
22
- s_name = name.replace(".", "")
23
- self.m_name2s_name.update({name: s_name})
24
- self.register_buffer(s_name, p.clone().detach().data)
25
-
26
- self.collected_params = []
27
-
28
- def forward(self, model):
29
- decay = self.decay
30
-
31
- if self.num_updates >= 0:
32
- self.num_updates += 1
33
- decay = min(self.decay, (1 + self.num_updates) / (10 + self.num_updates))
34
-
35
- one_minus_decay = 1.0 - decay
36
-
37
- with torch.no_grad():
38
- m_param = dict(model.named_parameters())
39
- shadow_params = dict(self.named_buffers())
40
-
41
- for key in m_param:
42
- if m_param[key].requires_grad:
43
- sname = self.m_name2s_name[key]
44
- shadow_params[sname] = shadow_params[sname].type_as(m_param[key])
45
- shadow_params[sname].sub_(
46
- one_minus_decay * (shadow_params[sname] - m_param[key])
47
- )
48
- else:
49
- assert not key in self.m_name2s_name
50
-
51
- def copy_to(self, model):
52
- m_param = dict(model.named_parameters())
53
- shadow_params = dict(self.named_buffers())
54
- for key in m_param:
55
- if m_param[key].requires_grad:
56
- m_param[key].data.copy_(shadow_params[self.m_name2s_name[key]].data)
57
- else:
58
- assert not key in self.m_name2s_name
59
-
60
- def store(self, parameters):
61
- """
62
- Save the current parameters for restoring later.
63
- Args:
64
- parameters: Iterable of `torch.nn.Parameter`; the parameters to be
65
- temporarily stored.
66
- """
67
- self.collected_params = [param.clone() for param in parameters]
68
-
69
- def restore(self, parameters):
70
- """
71
- Restore the parameters stored with the `store` method.
72
- Useful to validate the model with EMA parameters without affecting the
73
- original optimization process. Store the parameters before the
74
- `copy_to` method. After validation (or model saving), use this to
75
- restore the former parameters.
76
- Args:
77
- parameters: Iterable of `torch.nn.Parameter`; the parameters to be
78
- updated with the stored parameters.
79
- """
80
- for c_param, param in zip(self.collected_params, parameters):
81
- param.data.copy_(c_param.data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AIWaves/SOP_Generation-single/Action/base_action.py DELETED
@@ -1,51 +0,0 @@
1
- from Memory import Memory
2
- from utils import extract
3
- import os
4
- class Action:
5
- """
6
- The basic action unit of agent
7
- """
8
- def __init__(self,**kwargs):
9
- self.response = None
10
- self.is_user = False
11
- self.res_dict = {}
12
- self.name = ""
13
- self.role = ""
14
- for key,value in kwargs.items():
15
- setattr(self,key,value)
16
-
17
-
18
- def process(self):
19
- """
20
- processing action
21
- Rerutn : memory(Memory)
22
- """
23
- response = self.response
24
- send_name = self.name
25
- send_role = self.role
26
- all = ""
27
- for res in response:
28
- all += res
29
- parse = f"{send_name}:"
30
-
31
- # 将里面对话的第三人称删了
32
- # The third person in the dialogue was deleted.
33
- while parse in all:
34
- index = all.index(parse) + len(parse)
35
- all = all[index:]
36
-
37
- if not self.is_user:
38
- print(f"{send_name}({send_role}):{all}")
39
- # for software
40
- if "<title>" in all:
41
- title = extract(all,"title")
42
- title = "main.py" if title == "" else title
43
- python = extract(all,"python")
44
- os.makedirs("output_code", exist_ok=True)
45
- file_name = "output_code/" + title
46
- with open(file_name, "w", encoding="utf-8") as f:
47
- f.write(python)
48
- memory = Memory(send_role, send_name, all)
49
- return memory
50
-
51
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AchyuthGamer/OpenGPT-Chat-UI/src/styles/highlight-js.css DELETED
@@ -1 +0,0 @@
1
- @import "highlight.js/styles/atom-one-dark";
 
 
spaces/AchyuthGamer/OpenGPT/client/js/highlightjs-copy.min.js DELETED
@@ -1 +0,0 @@
1
- class CopyButtonPlugin{constructor(options={}){self.hook=options.hook;self.callback=options.callback}"after:highlightElement"({el,text}){let button=Object.assign(document.createElement("button"),{innerHTML:"Copy",className:"hljs-copy-button"});button.dataset.copied=false;el.parentElement.classList.add("hljs-copy-wrapper");el.parentElement.appendChild(button);el.parentElement.style.setProperty("--hljs-theme-background",window.getComputedStyle(el).backgroundColor);button.onclick=function(){if(!navigator.clipboard)return;let newText=text;if(hook&&typeof hook==="function"){newText=hook(text,el)||text}navigator.clipboard.writeText(newText).then(function(){button.innerHTML="Copied!";button.dataset.copied=true;let alert=Object.assign(document.createElement("div"),{role:"status",className:"hljs-copy-alert",innerHTML:"Copied to clipboard"});el.parentElement.appendChild(alert);setTimeout(()=>{button.innerHTML="Copy";button.dataset.copied=false;el.parentElement.removeChild(alert);alert=null},2e3)}).then(function(){if(typeof callback==="function")return callback(newText,el)})}}}
 
 
spaces/AchyuthGamer/jondurbin-airoboros-gpt-3.5-turbo-100k-7b/app.py DELETED
@@ -1,3 +0,0 @@
1
- import gradio as gr
2
-
3
- gr.Interface.load("models/jondurbin/airoboros-gpt-3.5-turbo-100k-7b").launch()
 
 
 
 
spaces/Adesoji1/Panel_PDF_QA/Dockerfile DELETED
@@ -1,15 +0,0 @@
1
- FROM python:3.9
2
-
3
- WORKDIR /code
4
-
5
- COPY ./requirements.txt /code/requirements.txt
6
- RUN python3 -m pip install --no-cache-dir --upgrade pip
7
- RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
-
9
- COPY . .
10
-
11
- CMD ["panel", "serve", "/code/LangChain_QA_Panel_App.ipynb", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "adesoji1-panel-pdf-qa.hf.space", "--allow-websocket-origin", "0.0.0.0:7860"]
12
- RUN mkdir /.cache
13
- RUN chmod 777 /.cache
14
- RUN mkdir .chroma
15
- RUN chmod 777 .chroma
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AgentVerse/agentVerse/agentverse/memory/vectorstore.py DELETED
@@ -1,63 +0,0 @@
1
- from typing import List, Union
2
-
3
- from pydantic import Field
4
-
5
- from agentverse.message import Message
6
- from agentverse.llms import BaseLLM
7
- from agentverse.llms.openai import get_embedding, OpenAIChat
8
-
9
-
10
- from . import memory_registry
11
- from .base import BaseMemory
12
-
13
-
14
-
15
- @memory_registry.register("vectorstore")
16
- class VectorStoreMemory(BaseMemory):
17
-
18
- """
19
-
20
- The main difference of this class with chat_history is that this class treat memory as a dict
21
-
22
- treat message.content as memory
23
-
24
- Attributes:
25
- messages (List[Message]) : used to store messages, message.content is the key of embeddings.
26
- embedding2memory (dict) : `key` is the embedding and `value` is the message
27
- memory2embedding (dict) : `key` is the message and `value` is the embedding
28
- llm (BaseLLM) : llm used to get embeddings
29
-
30
-
31
- Methods:
32
- add_message : Additionally, add the embedding to embeddings
33
-
34
- """
35
-
36
- messages: List[Message] = Field(default=[])
37
- embedding2memory: dict = {}
38
- memory2embedding: dict = {}
39
- llm: BaseLLM = OpenAIChat(model="gpt-4")
40
-
41
- def add_message(self, messages: List[Message]) -> None:
42
- for message in messages:
43
- self.messages.append(message)
44
- memory_embedding = get_embedding(message.content)
45
- self.embedding2memory[memory_embedding] = message.content
46
- self.memory2embedding[message.content] = memory_embedding
47
-
48
- def to_string(self, add_sender_prefix: bool = False) -> str:
49
- if add_sender_prefix:
50
- return "\n".join(
51
- [
52
- f"[{message.sender}]: {message.content}"
53
- if message.sender != ""
54
- else message.content
55
- for message in self.messages
56
- ]
57
- )
58
- else:
59
- return "\n".join([message.content for message in self.messages])
60
-
61
- def reset(self) -> None:
62
- self.messages = []
63
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/spinner/bars/Factory.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import Bars from './Bars';
2
- import Base from '../base/Base';
3
-
4
- export default function Factory(
5
- config?: Base.IConfig
6
- ): Bars;
 
 
 
 
 
 
 
spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/ui/menu/Factory.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import Menu from './Menu';
2
-
3
- export default function (
4
- config?: Menu.IConfig
5
- ): Menu;
 
 
 
 
 
 
spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/docs/source/en/api/schedulers/stochastic_karras_ve.md DELETED
@@ -1,20 +0,0 @@
1
- <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
- the License. You may obtain a copy of the License at
5
-
6
- http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
- specific language governing permissions and limitations under the License.
11
- -->
12
-
13
- # Variance exploding, stochastic sampling from Karras et. al
14
-
15
- ## Overview
16
-
17
- Original paper can be found [here](https://arxiv.org/abs/2206.00364).
18
-
19
- ## KarrasVeScheduler
20
- [[autodoc]] KarrasVeScheduler
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/src/diffusers/utils/accelerate_utils.py DELETED
@@ -1,48 +0,0 @@
1
- # Copyright 2023 The HuggingFace Team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """
15
- Accelerate utilities: Utilities related to accelerate
16
- """
17
-
18
- from packaging import version
19
-
20
- from .import_utils import is_accelerate_available
21
-
22
-
23
- if is_accelerate_available():
24
- import accelerate
25
-
26
-
27
- def apply_forward_hook(method):
28
- """
29
- Decorator that applies a registered CpuOffload hook to an arbitrary function rather than `forward`. This is useful
30
- for cases where a PyTorch module provides functions other than `forward` that should trigger a move to the
31
- appropriate acceleration device. This is the case for `encode` and `decode` in [`AutoencoderKL`].
32
-
33
- This decorator looks inside the internal `_hf_hook` property to find a registered offload hook.
34
-
35
- :param method: The method to decorate. This method should be a method of a PyTorch module.
36
- """
37
- if not is_accelerate_available():
38
- return method
39
- accelerate_version = version.parse(accelerate.__version__).base_version
40
- if version.parse(accelerate_version) < version.parse("0.17.0"):
41
- return method
42
-
43
- def wrapper(self, *args, **kwargs):
44
- if hasattr(self, "_hf_hook") and hasattr(self._hf_hook, "pre_forward"):
45
- self._hf_hook.pre_forward(self)
46
- return method(self, *args, **kwargs)
47
-
48
- return wrapper
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Andy1621/uniformer_image_detection/configs/paa/paa_r50_fpn_2x_coco.py DELETED
@@ -1,3 +0,0 @@
1
- _base_ = './paa_r50_fpn_1x_coco.py'
2
- lr_config = dict(step=[16, 22])
3
- runner = dict(type='EpochBasedRunner', max_epochs=24)
 
 
 
 
spaces/Andy1621/uniformer_image_detection/mmdet/core/evaluation/class_names.py DELETED
@@ -1,116 +0,0 @@
1
- import mmcv
2
-
3
-
4
- def wider_face_classes():
5
- return ['face']
6
-
7
-
8
- def voc_classes():
9
- return [
10
- 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat',
11
- 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person',
12
- 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'
13
- ]
14
-
15
-
16
- def imagenet_det_classes():
17
- return [
18
- 'accordion', 'airplane', 'ant', 'antelope', 'apple', 'armadillo',
19
- 'artichoke', 'axe', 'baby_bed', 'backpack', 'bagel', 'balance_beam',
20
- 'banana', 'band_aid', 'banjo', 'baseball', 'basketball', 'bathing_cap',
21
- 'beaker', 'bear', 'bee', 'bell_pepper', 'bench', 'bicycle', 'binder',
22
- 'bird', 'bookshelf', 'bow_tie', 'bow', 'bowl', 'brassiere', 'burrito',
23
- 'bus', 'butterfly', 'camel', 'can_opener', 'car', 'cart', 'cattle',
24
- 'cello', 'centipede', 'chain_saw', 'chair', 'chime', 'cocktail_shaker',
25
- 'coffee_maker', 'computer_keyboard', 'computer_mouse', 'corkscrew',
26
- 'cream', 'croquet_ball', 'crutch', 'cucumber', 'cup_or_mug', 'diaper',
27
- 'digital_clock', 'dishwasher', 'dog', 'domestic_cat', 'dragonfly',
28
- 'drum', 'dumbbell', 'electric_fan', 'elephant', 'face_powder', 'fig',
29
- 'filing_cabinet', 'flower_pot', 'flute', 'fox', 'french_horn', 'frog',
30
- 'frying_pan', 'giant_panda', 'goldfish', 'golf_ball', 'golfcart',
31
- 'guacamole', 'guitar', 'hair_dryer', 'hair_spray', 'hamburger',
32
- 'hammer', 'hamster', 'harmonica', 'harp', 'hat_with_a_wide_brim',
33
- 'head_cabbage', 'helmet', 'hippopotamus', 'horizontal_bar', 'horse',
34
- 'hotdog', 'iPod', 'isopod', 'jellyfish', 'koala_bear', 'ladle',
35
- 'ladybug', 'lamp', 'laptop', 'lemon', 'lion', 'lipstick', 'lizard',
36
- 'lobster', 'maillot', 'maraca', 'microphone', 'microwave', 'milk_can',
37
- 'miniskirt', 'monkey', 'motorcycle', 'mushroom', 'nail', 'neck_brace',
38
- 'oboe', 'orange', 'otter', 'pencil_box', 'pencil_sharpener', 'perfume',
39
- 'person', 'piano', 'pineapple', 'ping-pong_ball', 'pitcher', 'pizza',
40
- 'plastic_bag', 'plate_rack', 'pomegranate', 'popsicle', 'porcupine',
41
- 'power_drill', 'pretzel', 'printer', 'puck', 'punching_bag', 'purse',
42
- 'rabbit', 'racket', 'ray', 'red_panda', 'refrigerator',
43
- 'remote_control', 'rubber_eraser', 'rugby_ball', 'ruler',
44
- 'salt_or_pepper_shaker', 'saxophone', 'scorpion', 'screwdriver',
45
- 'seal', 'sheep', 'ski', 'skunk', 'snail', 'snake', 'snowmobile',
46
- 'snowplow', 'soap_dispenser', 'soccer_ball', 'sofa', 'spatula',
47
- 'squirrel', 'starfish', 'stethoscope', 'stove', 'strainer',
48
- 'strawberry', 'stretcher', 'sunglasses', 'swimming_trunks', 'swine',
49
- 'syringe', 'table', 'tape_player', 'tennis_ball', 'tick', 'tie',
50
- 'tiger', 'toaster', 'traffic_light', 'train', 'trombone', 'trumpet',
51
- 'turtle', 'tv_or_monitor', 'unicycle', 'vacuum', 'violin',
52
- 'volleyball', 'waffle_iron', 'washer', 'water_bottle', 'watercraft',
53
- 'whale', 'wine_bottle', 'zebra'
54
- ]
55
-
56
-
57
- def imagenet_vid_classes():
58
- return [
59
- 'airplane', 'antelope', 'bear', 'bicycle', 'bird', 'bus', 'car',
60
- 'cattle', 'dog', 'domestic_cat', 'elephant', 'fox', 'giant_panda',
61
- 'hamster', 'horse', 'lion', 'lizard', 'monkey', 'motorcycle', 'rabbit',
62
- 'red_panda', 'sheep', 'snake', 'squirrel', 'tiger', 'train', 'turtle',
63
- 'watercraft', 'whale', 'zebra'
64
- ]
65
-
66
-
67
- def coco_classes():
68
- return [
69
- 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train',
70
- 'truck', 'boat', 'traffic_light', 'fire_hydrant', 'stop_sign',
71
- 'parking_meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep',
72
- 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella',
73
- 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard',
74
- 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard',
75
- 'surfboard', 'tennis_racket', 'bottle', 'wine_glass', 'cup', 'fork',
76
- 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange',
77
- 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'chair',
78
- 'couch', 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv',
79
- 'laptop', 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave',
80
- 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
81
- 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush'
82
- ]
83
-
84
-
85
- def cityscapes_classes():
86
- return [
87
- 'person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle',
88
- 'bicycle'
89
- ]
90
-
91
-
92
- dataset_aliases = {
93
- 'voc': ['voc', 'pascal_voc', 'voc07', 'voc12'],
94
- 'imagenet_det': ['det', 'imagenet_det', 'ilsvrc_det'],
95
- 'imagenet_vid': ['vid', 'imagenet_vid', 'ilsvrc_vid'],
96
- 'coco': ['coco', 'mscoco', 'ms_coco'],
97
- 'wider_face': ['WIDERFaceDataset', 'wider_face', 'WIDERFace'],
98
- 'cityscapes': ['cityscapes']
99
- }
100
-
101
-
102
- def get_classes(dataset):
103
- """Get class names of a dataset."""
104
- alias2name = {}
105
- for name, aliases in dataset_aliases.items():
106
- for alias in aliases:
107
- alias2name[alias] = name
108
-
109
- if mmcv.is_str(dataset):
110
- if dataset in alias2name:
111
- labels = eval(alias2name[dataset] + '_classes()')
112
- else:
113
- raise ValueError(f'Unrecognized dataset: {dataset}')
114
- else:
115
- raise TypeError(f'dataset must a str, but got {type(dataset)}')
116
- return labels
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AnishKumbhar/ChatBot/text-generation-webui-main/extensions/superbooga/script.py DELETED
@@ -1,260 +0,0 @@
1
- import re
2
- import textwrap
3
-
4
- import gradio as gr
5
- from bs4 import BeautifulSoup
6
-
7
- from modules import chat
8
- from modules.logging_colors import logger
9
-
10
- from .chromadb import add_chunks_to_collector, make_collector
11
- from .download_urls import download_urls
12
-
13
- params = {
14
- 'chunk_count': 5,
15
- 'chunk_count_initial': 10,
16
- 'time_weight': 0,
17
- 'chunk_length': 700,
18
- 'chunk_separator': '',
19
- 'strong_cleanup': False,
20
- 'threads': 4,
21
- }
22
-
23
- collector = make_collector()
24
- chat_collector = make_collector()
25
-
26
-
27
- def feed_data_into_collector(corpus, chunk_len, chunk_sep):
28
- global collector
29
-
30
- # Defining variables
31
- chunk_len = int(chunk_len)
32
- chunk_sep = chunk_sep.replace(r'\n', '\n')
33
- cumulative = ''
34
-
35
- # Breaking the data into chunks and adding those to the db
36
- cumulative += "Breaking the input dataset...\n\n"
37
- yield cumulative
38
- if chunk_sep:
39
- data_chunks = corpus.split(chunk_sep)
40
- data_chunks = [[data_chunk[i:i + chunk_len] for i in range(0, len(data_chunk), chunk_len)] for data_chunk in data_chunks]
41
- data_chunks = [x for y in data_chunks for x in y]
42
- else:
43
- data_chunks = [corpus[i:i + chunk_len] for i in range(0, len(corpus), chunk_len)]
44
-
45
- cumulative += f"{len(data_chunks)} chunks have been found.\n\nAdding the chunks to the database...\n\n"
46
- yield cumulative
47
- add_chunks_to_collector(data_chunks, collector)
48
- cumulative += "Done."
49
- yield cumulative
50
-
51
-
52
- def feed_file_into_collector(file, chunk_len, chunk_sep):
53
- yield 'Reading the input dataset...\n\n'
54
- text = file.decode('utf-8')
55
- for i in feed_data_into_collector(text, chunk_len, chunk_sep):
56
- yield i
57
-
58
-
59
- def feed_url_into_collector(urls, chunk_len, chunk_sep, strong_cleanup, threads):
60
- all_text = ''
61
- cumulative = ''
62
-
63
- urls = urls.strip().split('\n')
64
- cumulative += f'Loading {len(urls)} URLs with {threads} threads...\n\n'
65
- yield cumulative
66
- for update, contents in download_urls(urls, threads=threads):
67
- yield cumulative + update
68
-
69
- cumulative += 'Processing the HTML sources...'
70
- yield cumulative
71
- for content in contents:
72
- soup = BeautifulSoup(content, features="lxml")
73
- for script in soup(["script", "style"]):
74
- script.extract()
75
-
76
- strings = soup.stripped_strings
77
- if strong_cleanup:
78
- strings = [s for s in strings if re.search("[A-Za-z] ", s)]
79
-
80
- text = '\n'.join([s.strip() for s in strings])
81
- all_text += text
82
-
83
- for i in feed_data_into_collector(all_text, chunk_len, chunk_sep):
84
- yield i
85
-
86
-
87
- def apply_settings(chunk_count, chunk_count_initial, time_weight):
88
- global params
89
- params['chunk_count'] = int(chunk_count)
90
- params['chunk_count_initial'] = int(chunk_count_initial)
91
- params['time_weight'] = time_weight
92
- settings_to_display = {k: params[k] for k in params if k in ['chunk_count', 'chunk_count_initial', 'time_weight']}
93
- yield f"The following settings are now active: {str(settings_to_display)}"
94
-
95
-
96
- def custom_generate_chat_prompt(user_input, state, **kwargs):
97
- global chat_collector
98
-
99
- # get history as being modified when using regenerate.
100
- history = kwargs['history']
101
-
102
- if state['mode'] == 'instruct':
103
- results = collector.get_sorted(user_input, n_results=params['chunk_count'])
104
- additional_context = '\nYour reply should be based on the context below:\n\n' + '\n'.join(results)
105
- user_input += additional_context
106
- else:
107
-
108
- def make_single_exchange(id_):
109
- output = ''
110
- output += f"{state['name1']}: {history['internal'][id_][0]}\n"
111
- output += f"{state['name2']}: {history['internal'][id_][1]}\n"
112
- return output
113
-
114
- if len(history['internal']) > params['chunk_count'] and user_input != '':
115
- chunks = []
116
- hist_size = len(history['internal'])
117
- for i in range(hist_size - 1):
118
- chunks.append(make_single_exchange(i))
119
-
120
- add_chunks_to_collector(chunks, chat_collector)
121
- query = '\n'.join(history['internal'][-1] + [user_input])
122
- try:
123
- best_ids = chat_collector.get_ids_sorted(query, n_results=params['chunk_count'], n_initial=params['chunk_count_initial'], time_weight=params['time_weight'])
124
- additional_context = '\n'
125
- for id_ in best_ids:
126
- if history['internal'][id_][0] != '<|BEGIN-VISIBLE-CHAT|>':
127
- additional_context += make_single_exchange(id_)
128
-
129
- logger.warning(f'Adding the following new context:\n{additional_context}')
130
- state['context'] = state['context'].strip() + '\n' + additional_context
131
- kwargs['history'] = {
132
- 'internal': [history['internal'][i] for i in range(hist_size) if i not in best_ids],
133
- 'visible': ''
134
- }
135
- except RuntimeError:
136
- logger.error("Couldn't query the database, moving on...")
137
-
138
- return chat.generate_chat_prompt(user_input, state, **kwargs)
139
-
140
-
141
- def remove_special_tokens(string):
142
- pattern = r'(<\|begin-user-input\|>|<\|end-user-input\|>|<\|injection-point\|>)'
143
- return re.sub(pattern, '', string)
144
-
145
-
146
- def input_modifier(string, state, is_chat=False):
147
- if is_chat:
148
- return string
149
-
150
- # Find the user input
151
- pattern = re.compile(r"<\|begin-user-input\|>(.*?)<\|end-user-input\|>", re.DOTALL)
152
- match = re.search(pattern, string)
153
- if match:
154
- user_input = match.group(1).strip()
155
-
156
- # Get the most similar chunks
157
- results = collector.get_sorted(user_input, n_results=params['chunk_count'])
158
-
159
- # Make the injection
160
- string = string.replace('<|injection-point|>', '\n'.join(results))
161
-
162
- return remove_special_tokens(string)
163
-
164
-
165
- def ui():
166
- with gr.Accordion("Click for more information...", open=False):
167
- gr.Markdown(textwrap.dedent("""
168
-
169
- ## About
170
-
171
- This extension takes a dataset as input, breaks it into chunks, and adds the result to a local/offline Chroma database.
172
-
173
- The database is then queried during inference time to get the excerpts that are closest to your input. The idea is to create an arbitrarily large pseudo context.
174
-
175
- The core methodology was developed and contributed by kaiokendev, who is working on improvements to the method in this repository: https://github.com/kaiokendev/superbig
176
-
177
- ## Data input
178
-
179
- Start by entering some data in the interface below and then clicking on "Load data".
180
-
181
- Each time you load some new data, the old chunks are discarded.
182
-
183
- ## Chat mode
184
-
185
- #### Instruct
186
-
187
- On each turn, the chunks will be compared to your current input and the most relevant matches will be appended to the input in the following format:
188
-
189
- ```
190
- Consider the excerpts below as additional context:
191
- ...
192
- ```
193
-
194
- The injection doesn't make it into the chat history. It is only used in the current generation.
195
-
196
- #### Regular chat
197
-
198
- The chunks from the external data sources are ignored, and the chroma database is built based on the chat history instead. The most relevant past exchanges relative to the present input are added to the context string. This way, the extension acts as a long term memory.
199
-
200
- ## Notebook/default modes
201
-
202
- Your question must be manually specified between `<|begin-user-input|>` and `<|end-user-input|>` tags, and the injection point must be specified with `<|injection-point|>`.
203
-
204
- The special tokens mentioned above (`<|begin-user-input|>`, `<|end-user-input|>`, and `<|injection-point|>`) are removed in the background before the text generation begins.
205
-
206
- Here is an example in Vicuna 1.1 format:
207
-
208
- ```
209
- A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
210
-
211
- USER:
212
-
213
- <|begin-user-input|>
214
- What datasets are mentioned in the text below?
215
- <|end-user-input|>
216
-
217
- <|injection-point|>
218
-
219
- ASSISTANT:
220
- ```
221
-
222
- ⚠️ For best results, make sure to remove the spaces and new line characters after `ASSISTANT:`.
223
-
224
- *This extension is currently experimental and under development.*
225
-
226
- """))
227
-
228
- with gr.Row():
229
- with gr.Column(min_width=600):
230
- with gr.Tab("Text input"):
231
- data_input = gr.Textbox(lines=20, label='Input data')
232
- update_data = gr.Button('Load data')
233
-
234
- with gr.Tab("URL input"):
235
- url_input = gr.Textbox(lines=10, label='Input URLs', info='Enter one or more URLs separated by newline characters.')
236
- strong_cleanup = gr.Checkbox(value=params['strong_cleanup'], label='Strong cleanup', info='Only keeps html elements that look like long-form text.')
237
- threads = gr.Number(value=params['threads'], label='Threads', info='The number of threads to use while downloading the URLs.', precision=0)
238
- update_url = gr.Button('Load data')
239
-
240
- with gr.Tab("File input"):
241
- file_input = gr.File(label='Input file', type='binary')
242
- update_file = gr.Button('Load data')
243
-
244
- with gr.Tab("Generation settings"):
245
- chunk_count = gr.Number(value=params['chunk_count'], label='Chunk count', info='The number of closest-matching chunks to include in the prompt.')
246
- gr.Markdown('Time weighting (optional, used in to make recently added chunks more likely to appear)')
247
- time_weight = gr.Slider(0, 1, value=params['time_weight'], label='Time weight', info='Defines the strength of the time weighting. 0 = no time weighting.')
248
- chunk_count_initial = gr.Number(value=params['chunk_count_initial'], label='Initial chunk count', info='The number of closest-matching chunks retrieved for time weight reordering in chat mode. This should be >= chunk count. -1 = All chunks are retrieved. Only used if time_weight > 0.')
249
-
250
- update_settings = gr.Button('Apply changes')
251
-
252
- chunk_len = gr.Number(value=params['chunk_length'], label='Chunk length', info='In characters, not tokens. This value is used when you click on "Load data".')
253
- chunk_sep = gr.Textbox(value=params['chunk_separator'], label='Chunk separator', info='Used to manually split chunks. Manually split chunks longer than chunk length are split again. This value is used when you click on "Load data".')
254
- with gr.Column():
255
- last_updated = gr.Markdown()
256
-
257
- update_data.click(feed_data_into_collector, [data_input, chunk_len, chunk_sep], last_updated, show_progress=False)
258
- update_url.click(feed_url_into_collector, [url_input, chunk_len, chunk_sep, strong_cleanup, threads], last_updated, show_progress=False)
259
- update_file.click(feed_file_into_collector, [file_input, chunk_len, chunk_sep], last_updated, show_progress=False)
260
- update_settings.click(apply_settings, [chunk_count, chunk_count_initial, time_weight], last_updated, show_progress=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/ops/pixel_group.py DELETED
@@ -1,75 +0,0 @@
1
- # Copyright (c) OpenMMLab. All rights reserved.
2
- import numpy as np
3
- import torch
4
-
5
- from ..utils import ext_loader
6
-
7
- ext_module = ext_loader.load_ext('_ext', ['pixel_group'])
8
-
9
-
10
- def pixel_group(score, mask, embedding, kernel_label, kernel_contour,
11
- kernel_region_num, distance_threshold):
12
- """Group pixels into text instances, which is widely used text detection
13
- methods.
14
-
15
- Arguments:
16
- score (np.array or Tensor): The foreground score with size hxw.
17
- mask (np.array or Tensor): The foreground mask with size hxw.
18
- embedding (np.array or Tensor): The embedding with size hxwxc to
19
- distinguish instances.
20
- kernel_label (np.array or Tensor): The instance kernel index with
21
- size hxw.
22
- kernel_contour (np.array or Tensor): The kernel contour with size hxw.
23
- kernel_region_num (int): The instance kernel region number.
24
- distance_threshold (float): The embedding distance threshold between
25
- kernel and pixel in one instance.
26
-
27
- Returns:
28
- pixel_assignment (List[List[float]]): The instance coordinate list.
29
- Each element consists of averaged confidence, pixel number, and
30
- coordinates (x_i, y_i for all pixels) in order.
31
- """
32
- assert isinstance(score, (torch.Tensor, np.ndarray))
33
- assert isinstance(mask, (torch.Tensor, np.ndarray))
34
- assert isinstance(embedding, (torch.Tensor, np.ndarray))
35
- assert isinstance(kernel_label, (torch.Tensor, np.ndarray))
36
- assert isinstance(kernel_contour, (torch.Tensor, np.ndarray))
37
- assert isinstance(kernel_region_num, int)
38
- assert isinstance(distance_threshold, float)
39
-
40
- if isinstance(score, np.ndarray):
41
- score = torch.from_numpy(score)
42
- if isinstance(mask, np.ndarray):
43
- mask = torch.from_numpy(mask)
44
- if isinstance(embedding, np.ndarray):
45
- embedding = torch.from_numpy(embedding)
46
- if isinstance(kernel_label, np.ndarray):
47
- kernel_label = torch.from_numpy(kernel_label)
48
- if isinstance(kernel_contour, np.ndarray):
49
- kernel_contour = torch.from_numpy(kernel_contour)
50
-
51
- if torch.__version__ == 'parrots':
52
- label = ext_module.pixel_group(
53
- score,
54
- mask,
55
- embedding,
56
- kernel_label,
57
- kernel_contour,
58
- kernel_region_num=kernel_region_num,
59
- distance_threshold=distance_threshold)
60
- label = label.tolist()
61
- label = label[0]
62
- list_index = kernel_region_num
63
- pixel_assignment = []
64
- for x in range(kernel_region_num):
65
- pixel_assignment.append(
66
- np.array(
67
- label[list_index:list_index + int(label[x])],
68
- dtype=np.float))
69
- list_index = list_index + int(label[x])
70
- else:
71
- pixel_assignment = ext_module.pixel_group(score, mask, embedding,
72
- kernel_label, kernel_contour,
73
- kernel_region_num,
74
- distance_threshold)
75
- return pixel_assignment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/AquaSuisei/ChatGPTXE/run_macOS.command DELETED
@@ -1,25 +0,0 @@
1
- #!/bin/bash
2
-
3
- # 获取脚本所在目录
4
- script_dir=$(dirname "$0")
5
-
6
- # 将工作目录更改为脚本所在目录
7
- cd "$script_dir"
8
-
9
- # 检查Git仓库是否有更新
10
- git remote update
11
- pwd
12
-
13
- if ! git status -uno | grep 'up to date' > /dev/null; then
14
- # 如果有更新,关闭当前运行的服务器
15
- pkill -f ChuanhuChatbot.py
16
-
17
- # 拉取最新更改
18
- git pull
19
-
20
- # 安装依赖
21
- pip3 install -r requirements.txt
22
-
23
- # 重新启动服务器
24
- nohup python3 ChuanhuChatbot.py &
25
- fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/ArchitSharma/Digital-Photo-Color-Restoration/src/deoldify/augs.py DELETED
@@ -1,29 +0,0 @@
1
- import random
2
-
3
- from fastai.vision.image import TfmPixel
4
-
5
- # Contributed by Rani Horev. Thank you!
6
- def _noisify(
7
- x, pct_pixels_min: float = 0.001, pct_pixels_max: float = 0.4, noise_range: int = 30
8
- ):
9
- if noise_range > 255 or noise_range < 0:
10
- raise Exception("noise_range must be between 0 and 255, inclusively.")
11
-
12
- h, w = x.shape[1:]
13
- img_size = h * w
14
- mult = 10000.0
15
- pct_pixels = (
16
- random.randrange(int(pct_pixels_min * mult), int(pct_pixels_max * mult)) / mult
17
- )
18
- noise_count = int(img_size * pct_pixels)
19
-
20
- for ii in range(noise_count):
21
- yy = random.randrange(h)
22
- xx = random.randrange(w)
23
- noise = random.randrange(-noise_range, noise_range) / 255.0
24
- x[:, yy, xx].add_(noise)
25
-
26
- return x
27
-
28
-
29
- noisify = TfmPixel(_noisify)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/ArtGAN/Diffusion-API/diffusion_webui/utils/preprocces_utils.py DELETED
@@ -1,94 +0,0 @@
1
- from controlnet_aux import (
2
- CannyDetector,
3
- ContentShuffleDetector,
4
- HEDdetector,
5
- LineartAnimeDetector,
6
- LineartDetector,
7
- MediapipeFaceDetector,
8
- MidasDetector,
9
- MLSDdetector,
10
- NormalBaeDetector,
11
- OpenposeDetector,
12
- PidiNetDetector,
13
- SamDetector,
14
- )
15
-
16
- import numpy as np
17
- import cv2
18
-
19
- def pad64(x):
20
- return int(np.ceil(float(x) / 64.0) * 64 - x)
21
-
22
- def HWC3(x):
23
- assert x.dtype == np.uint8
24
- if x.ndim == 2:
25
- x = x[:, :, None]
26
- assert x.ndim == 3
27
- H, W, C = x.shape
28
- assert C == 1 or C == 3 or C == 4
29
- if C == 3:
30
- return x
31
- if C == 1:
32
- return np.concatenate([x, x, x], axis=2)
33
- if C == 4:
34
- color = x[:, :, 0:3].astype(np.float32)
35
- alpha = x[:, :, 3:4].astype(np.float32) / 255.0
36
- y = color * alpha + 255.0 * (1.0 - alpha)
37
- y = y.clip(0, 255).astype(np.uint8)
38
- return y
39
-
40
- def safer_memory(x):
41
- return np.ascontiguousarray(x.copy()).copy()
42
-
43
-
44
- def resize_image_with_pad(input_image, resolution, skip_hwc3=False):
45
- if skip_hwc3:
46
- img = input_image
47
- else:
48
- img = HWC3(input_image)
49
-
50
- H_raw, W_raw, _ = img.shape
51
- k = float(resolution) / float(min(H_raw, W_raw))
52
- interpolation = cv2.INTER_CUBIC if k > 1 else cv2.INTER_AREA
53
- H_target = int(np.round(float(H_raw) * k))
54
- W_target = int(np.round(float(W_raw) * k))
55
- img = cv2.resize(img, (W_target, H_target), interpolation=interpolation)
56
- H_pad, W_pad = pad64(H_target), pad64(W_target)
57
- img_padded = np.pad(img, [[0, H_pad], [0, W_pad], [0, 0]], mode='edge')
58
-
59
- def remove_pad(x):
60
- return safer_memory(x[:H_target, :W_target])
61
-
62
- return safer_memory(img_padded), remove_pad
63
-
64
-
65
- def scribble_xdog(img, res=512, thr_a=32, **kwargs):
66
- img, remove_pad = resize_image_with_pad(img, res)
67
- g1 = cv2.GaussianBlur(img.astype(np.float32), (0, 0), 0.5)
68
- g2 = cv2.GaussianBlur(img.astype(np.float32), (0, 0), 5.0)
69
- dog = (255 - np.min(g2 - g1, axis=2)).clip(0, 255).astype(np.uint8)
70
- result = np.zeros_like(img, dtype=np.uint8)
71
- result[2 * (255 - dog) > thr_a] = 255
72
- return remove_pad(result), True
73
-
74
- def none_preprocces(image_path:str):
75
- return Image.open(image_path)
76
-
77
- PREPROCCES_DICT = {
78
- "Hed": HEDdetector.from_pretrained("lllyasviel/Annotators"),
79
- "Midas": MidasDetector.from_pretrained("lllyasviel/Annotators"),
80
- "MLSD": MLSDdetector.from_pretrained("lllyasviel/Annotators"),
81
- "Openpose": OpenposeDetector.from_pretrained("lllyasviel/Annotators"),
82
- "PidiNet": PidiNetDetector.from_pretrained("lllyasviel/Annotators"),
83
- "NormalBae": NormalBaeDetector.from_pretrained("lllyasviel/Annotators"),
84
- "Lineart": LineartDetector.from_pretrained("lllyasviel/Annotators"),
85
- "LineartAnime": LineartAnimeDetector.from_pretrained(
86
- "lllyasviel/Annotators"
87
- ),
88
- "Canny": CannyDetector(),
89
- "ContentShuffle": ContentShuffleDetector(),
90
- "MediapipeFace": MediapipeFaceDetector(),
91
- "ScribbleXDOG": scribble_xdog,
92
- "None": none_preprocces
93
- }
94
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/platformdirs/version.py DELETED
@@ -1,4 +0,0 @@
1
- # file generated by setuptools_scm
2
- # don't change, don't track in version control
3
- __version__ = version = '3.2.0'
4
- __version_tuple__ = version_tuple = (3, 2, 0)
 
 
 
 
 
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/pygments/lexer.py DELETED
@@ -1,883 +0,0 @@
1
- """
2
- pygments.lexer
3
- ~~~~~~~~~~~~~~
4
-
5
- Base lexer classes.
6
-
7
- :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
8
- :license: BSD, see LICENSE for details.
9
- """
10
-
11
- import re
12
- import sys
13
- import time
14
-
15
- from pip._vendor.pygments.filter import apply_filters, Filter
16
- from pip._vendor.pygments.filters import get_filter_by_name
17
- from pip._vendor.pygments.token import Error, Text, Other, Whitespace, _TokenType
18
- from pip._vendor.pygments.util import get_bool_opt, get_int_opt, get_list_opt, \
19
- make_analysator, Future, guess_decode
20
- from pip._vendor.pygments.regexopt import regex_opt
21
-
22
- __all__ = ['Lexer', 'RegexLexer', 'ExtendedRegexLexer', 'DelegatingLexer',
23
- 'LexerContext', 'include', 'inherit', 'bygroups', 'using', 'this',
24
- 'default', 'words', 'line_re']
25
-
26
- line_re = re.compile('.*?\n')
27
-
28
- _encoding_map = [(b'\xef\xbb\xbf', 'utf-8'),
29
- (b'\xff\xfe\0\0', 'utf-32'),
30
- (b'\0\0\xfe\xff', 'utf-32be'),
31
- (b'\xff\xfe', 'utf-16'),
32
- (b'\xfe\xff', 'utf-16be')]
33
-
34
- _default_analyse = staticmethod(lambda x: 0.0)
35
-
36
-
37
- class LexerMeta(type):
38
- """
39
- This metaclass automagically converts ``analyse_text`` methods into
40
- static methods which always return float values.
41
- """
42
-
43
- def __new__(mcs, name, bases, d):
44
- if 'analyse_text' in d:
45
- d['analyse_text'] = make_analysator(d['analyse_text'])
46
- return type.__new__(mcs, name, bases, d)
47
-
48
-
49
- class Lexer(metaclass=LexerMeta):
50
- """
51
- Lexer for a specific language.
52
-
53
- Basic options recognized:
54
- ``stripnl``
55
- Strip leading and trailing newlines from the input (default: True).
56
- ``stripall``
57
- Strip all leading and trailing whitespace from the input
58
- (default: False).
59
- ``ensurenl``
60
- Make sure that the input ends with a newline (default: True). This
61
- is required for some lexers that consume input linewise.
62
-
63
- .. versionadded:: 1.3
64
-
65
- ``tabsize``
66
- If given and greater than 0, expand tabs in the input (default: 0).
67
- ``encoding``
68
- If given, must be an encoding name. This encoding will be used to
69
- convert the input string to Unicode, if it is not already a Unicode
70
- string (default: ``'guess'``, which uses a simple UTF-8 / Locale /
71
- Latin1 detection. Can also be ``'chardet'`` to use the chardet
72
- library, if it is installed.
73
- ``inencoding``
74
- Overrides the ``encoding`` if given.
75
- """
76
-
77
- #: Name of the lexer
78
- name = None
79
-
80
- #: URL of the language specification/definition
81
- url = None
82
-
83
- #: Shortcuts for the lexer
84
- aliases = []
85
-
86
- #: File name globs
87
- filenames = []
88
-
89
- #: Secondary file name globs
90
- alias_filenames = []
91
-
92
- #: MIME types
93
- mimetypes = []
94
-
95
- #: Priority, should multiple lexers match and no content is provided
96
- priority = 0
97
-
98
- def __init__(self, **options):
99
- self.options = options
100
- self.stripnl = get_bool_opt(options, 'stripnl', True)
101
- self.stripall = get_bool_opt(options, 'stripall', False)
102
- self.ensurenl = get_bool_opt(options, 'ensurenl', True)
103
- self.tabsize = get_int_opt(options, 'tabsize', 0)
104
- self.encoding = options.get('encoding', 'guess')
105
- self.encoding = options.get('inencoding') or self.encoding
106
- self.filters = []
107
- for filter_ in get_list_opt(options, 'filters', ()):
108
- self.add_filter(filter_)
109
-
110
- def __repr__(self):
111
- if self.options:
112
- return '<pygments.lexers.%s with %r>' % (self.__class__.__name__,
113
- self.options)
114
- else:
115
- return '<pygments.lexers.%s>' % self.__class__.__name__
116
-
117
- def add_filter(self, filter_, **options):
118
- """
119
- Add a new stream filter to this lexer.
120
- """
121
- if not isinstance(filter_, Filter):
122
- filter_ = get_filter_by_name(filter_, **options)
123
- self.filters.append(filter_)
124
-
125
- def analyse_text(text):
126
- """
127
- Has to return a float between ``0`` and ``1`` that indicates
128
- if a lexer wants to highlight this text. Used by ``guess_lexer``.
129
- If this method returns ``0`` it won't highlight it in any case, if
130
- it returns ``1`` highlighting with this lexer is guaranteed.
131
-
132
- The `LexerMeta` metaclass automatically wraps this function so
133
- that it works like a static method (no ``self`` or ``cls``
134
- parameter) and the return value is automatically converted to
135
- `float`. If the return value is an object that is boolean `False`
136
- it's the same as if the return values was ``0.0``.
137
- """
138
-
139
- def get_tokens(self, text, unfiltered=False):
140
- """
141
- Return an iterable of (tokentype, value) pairs generated from
142
- `text`. If `unfiltered` is set to `True`, the filtering mechanism
143
- is bypassed even if filters are defined.
144
-
145
- Also preprocess the text, i.e. expand tabs and strip it if
146
- wanted and applies registered filters.
147
- """
148
- if not isinstance(text, str):
149
- if self.encoding == 'guess':
150
- text, _ = guess_decode(text)
151
- elif self.encoding == 'chardet':
152
- try:
153
- from pip._vendor import chardet
154
- except ImportError as e:
155
- raise ImportError('To enable chardet encoding guessing, '
156
- 'please install the chardet library '
157
- 'from http://chardet.feedparser.org/') from e
158
- # check for BOM first
159
- decoded = None
160
- for bom, encoding in _encoding_map:
161
- if text.startswith(bom):
162
- decoded = text[len(bom):].decode(encoding, 'replace')
163
- break
164
- # no BOM found, so use chardet
165
- if decoded is None:
166
- enc = chardet.detect(text[:1024]) # Guess using first 1KB
167
- decoded = text.decode(enc.get('encoding') or 'utf-8',
168
- 'replace')
169
- text = decoded
170
- else:
171
- text = text.decode(self.encoding)
172
- if text.startswith('\ufeff'):
173
- text = text[len('\ufeff'):]
174
- else:
175
- if text.startswith('\ufeff'):
176
- text = text[len('\ufeff'):]
177
-
178
- # text now *is* a unicode string
179
- text = text.replace('\r\n', '\n')
180
- text = text.replace('\r', '\n')
181
- if self.stripall:
182
- text = text.strip()
183
- elif self.stripnl:
184
- text = text.strip('\n')
185
- if self.tabsize > 0:
186
- text = text.expandtabs(self.tabsize)
187
- if self.ensurenl and not text.endswith('\n'):
188
- text += '\n'
189
-
190
- def streamer():
191
- for _, t, v in self.get_tokens_unprocessed(text):
192
- yield t, v
193
- stream = streamer()
194
- if not unfiltered:
195
- stream = apply_filters(stream, self.filters, self)
196
- return stream
197
-
198
- def get_tokens_unprocessed(self, text):
199
- """
200
- Return an iterable of (index, tokentype, value) pairs where "index"
201
- is the starting position of the token within the input text.
202
-
203
- In subclasses, implement this method as a generator to
204
- maximize effectiveness.
205
- """
206
- raise NotImplementedError
207
-
208
-
209
- class DelegatingLexer(Lexer):
210
- """
211
- This lexer takes two lexer as arguments. A root lexer and
212
- a language lexer. First everything is scanned using the language
213
- lexer, afterwards all ``Other`` tokens are lexed using the root
214
- lexer.
215
-
216
- The lexers from the ``template`` lexer package use this base lexer.
217
- """
218
-
219
- def __init__(self, _root_lexer, _language_lexer, _needle=Other, **options):
220
- self.root_lexer = _root_lexer(**options)
221
- self.language_lexer = _language_lexer(**options)
222
- self.needle = _needle
223
- Lexer.__init__(self, **options)
224
-
225
- def get_tokens_unprocessed(self, text):
226
- buffered = ''
227
- insertions = []
228
- lng_buffer = []
229
- for i, t, v in self.language_lexer.get_tokens_unprocessed(text):
230
- if t is self.needle:
231
- if lng_buffer:
232
- insertions.append((len(buffered), lng_buffer))
233
- lng_buffer = []
234
- buffered += v
235
- else:
236
- lng_buffer.append((i, t, v))
237
- if lng_buffer:
238
- insertions.append((len(buffered), lng_buffer))
239
- return do_insertions(insertions,
240
- self.root_lexer.get_tokens_unprocessed(buffered))
241
-
242
-
243
- # ------------------------------------------------------------------------------
244
- # RegexLexer and ExtendedRegexLexer
245
- #
246
-
247
-
248
- class include(str): # pylint: disable=invalid-name
249
- """
250
- Indicates that a state should include rules from another state.
251
- """
252
- pass
253
-
254
-
255
- class _inherit:
256
- """
257
- Indicates the a state should inherit from its superclass.
258
- """
259
- def __repr__(self):
260
- return 'inherit'
261
-
262
- inherit = _inherit() # pylint: disable=invalid-name
263
-
264
-
265
- class combined(tuple): # pylint: disable=invalid-name
266
- """
267
- Indicates a state combined from multiple states.
268
- """
269
-
270
- def __new__(cls, *args):
271
- return tuple.__new__(cls, args)
272
-
273
- def __init__(self, *args):
274
- # tuple.__init__ doesn't do anything
275
- pass
276
-
277
-
278
- class _PseudoMatch:
279
- """
280
- A pseudo match object constructed from a string.
281
- """
282
-
283
- def __init__(self, start, text):
284
- self._text = text
285
- self._start = start
286
-
287
- def start(self, arg=None):
288
- return self._start
289
-
290
- def end(self, arg=None):
291
- return self._start + len(self._text)
292
-
293
- def group(self, arg=None):
294
- if arg:
295
- raise IndexError('No such group')
296
- return self._text
297
-
298
- def groups(self):
299
- return (self._text,)
300
-
301
- def groupdict(self):
302
- return {}
303
-
304
-
305
- def bygroups(*args):
306
- """
307
- Callback that yields multiple actions for each group in the match.
308
- """
309
- def callback(lexer, match, ctx=None):
310
- for i, action in enumerate(args):
311
- if action is None:
312
- continue
313
- elif type(action) is _TokenType:
314
- data = match.group(i + 1)
315
- if data:
316
- yield match.start(i + 1), action, data
317
- else:
318
- data = match.group(i + 1)
319
- if data is not None:
320
- if ctx:
321
- ctx.pos = match.start(i + 1)
322
- for item in action(lexer,
323
- _PseudoMatch(match.start(i + 1), data), ctx):
324
- if item:
325
- yield item
326
- if ctx:
327
- ctx.pos = match.end()
328
- return callback
329
-
330
-
331
- class _This:
332
- """
333
- Special singleton used for indicating the caller class.
334
- Used by ``using``.
335
- """
336
-
337
- this = _This()
338
-
339
-
340
- def using(_other, **kwargs):
341
- """
342
- Callback that processes the match with a different lexer.
343
-
344
- The keyword arguments are forwarded to the lexer, except `state` which
345
- is handled separately.
346
-
347
- `state` specifies the state that the new lexer will start in, and can
348
- be an enumerable such as ('root', 'inline', 'string') or a simple
349
- string which is assumed to be on top of the root state.
350
-
351
- Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.
352
- """
353
- gt_kwargs = {}
354
- if 'state' in kwargs:
355
- s = kwargs.pop('state')
356
- if isinstance(s, (list, tuple)):
357
- gt_kwargs['stack'] = s
358
- else:
359
- gt_kwargs['stack'] = ('root', s)
360
-
361
- if _other is this:
362
- def callback(lexer, match, ctx=None):
363
- # if keyword arguments are given the callback
364
- # function has to create a new lexer instance
365
- if kwargs:
366
- # XXX: cache that somehow
367
- kwargs.update(lexer.options)
368
- lx = lexer.__class__(**kwargs)
369
- else:
370
- lx = lexer
371
- s = match.start()
372
- for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
373
- yield i + s, t, v
374
- if ctx:
375
- ctx.pos = match.end()
376
- else:
377
- def callback(lexer, match, ctx=None):
378
- # XXX: cache that somehow
379
- kwargs.update(lexer.options)
380
- lx = _other(**kwargs)
381
-
382
- s = match.start()
383
- for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
384
- yield i + s, t, v
385
- if ctx:
386
- ctx.pos = match.end()
387
- return callback
388
-
389
-
390
- class default:
391
- """
392
- Indicates a state or state action (e.g. #pop) to apply.
393
- For example default('#pop') is equivalent to ('', Token, '#pop')
394
- Note that state tuples may be used as well.
395
-
396
- .. versionadded:: 2.0
397
- """
398
- def __init__(self, state):
399
- self.state = state
400
-
401
-
402
- class words(Future):
403
- """
404
- Indicates a list of literal words that is transformed into an optimized
405
- regex that matches any of the words.
406
-
407
- .. versionadded:: 2.0
408
- """
409
- def __init__(self, words, prefix='', suffix=''):
410
- self.words = words
411
- self.prefix = prefix
412
- self.suffix = suffix
413
-
414
- def get(self):
415
- return regex_opt(self.words, prefix=self.prefix, suffix=self.suffix)
416
-
417
-
418
- class RegexLexerMeta(LexerMeta):
419
- """
420
- Metaclass for RegexLexer, creates the self._tokens attribute from
421
- self.tokens on the first instantiation.
422
- """
423
-
424
- def _process_regex(cls, regex, rflags, state):
425
- """Preprocess the regular expression component of a token definition."""
426
- if isinstance(regex, Future):
427
- regex = regex.get()
428
- return re.compile(regex, rflags).match
429
-
430
- def _process_token(cls, token):
431
- """Preprocess the token component of a token definition."""
432
- assert type(token) is _TokenType or callable(token), \
433
- 'token type must be simple type or callable, not %r' % (token,)
434
- return token
435
-
436
- def _process_new_state(cls, new_state, unprocessed, processed):
437
- """Preprocess the state transition action of a token definition."""
438
- if isinstance(new_state, str):
439
- # an existing state
440
- if new_state == '#pop':
441
- return -1
442
- elif new_state in unprocessed:
443
- return (new_state,)
444
- elif new_state == '#push':
445
- return new_state
446
- elif new_state[:5] == '#pop:':
447
- return -int(new_state[5:])
448
- else:
449
- assert False, 'unknown new state %r' % new_state
450
- elif isinstance(new_state, combined):
451
- # combine a new state from existing ones
452
- tmp_state = '_tmp_%d' % cls._tmpname
453
- cls._tmpname += 1
454
- itokens = []
455
- for istate in new_state:
456
- assert istate != new_state, 'circular state ref %r' % istate
457
- itokens.extend(cls._process_state(unprocessed,
458
- processed, istate))
459
- processed[tmp_state] = itokens
460
- return (tmp_state,)
461
- elif isinstance(new_state, tuple):
462
- # push more than one state
463
- for istate in new_state:
464
- assert (istate in unprocessed or
465
- istate in ('#pop', '#push')), \
466
- 'unknown new state ' + istate
467
- return new_state
468
- else:
469
- assert False, 'unknown new state def %r' % new_state
470
-
471
- def _process_state(cls, unprocessed, processed, state):
472
- """Preprocess a single state definition."""
473
- assert type(state) is str, "wrong state name %r" % state
474
- assert state[0] != '#', "invalid state name %r" % state
475
- if state in processed:
476
- return processed[state]
477
- tokens = processed[state] = []
478
- rflags = cls.flags
479
- for tdef in unprocessed[state]:
480
- if isinstance(tdef, include):
481
- # it's a state reference
482
- assert tdef != state, "circular state reference %r" % state
483
- tokens.extend(cls._process_state(unprocessed, processed,
484
- str(tdef)))
485
- continue
486
- if isinstance(tdef, _inherit):
487
- # should be processed already, but may not in the case of:
488
- # 1. the state has no counterpart in any parent
489
- # 2. the state includes more than one 'inherit'
490
- continue
491
- if isinstance(tdef, default):
492
- new_state = cls._process_new_state(tdef.state, unprocessed, processed)
493
- tokens.append((re.compile('').match, None, new_state))
494
- continue
495
-
496
- assert type(tdef) is tuple, "wrong rule def %r" % tdef
497
-
498
- try:
499
- rex = cls._process_regex(tdef[0], rflags, state)
500
- except Exception as err:
501
- raise ValueError("uncompilable regex %r in state %r of %r: %s" %
502
- (tdef[0], state, cls, err)) from err
503
-
504
- token = cls._process_token(tdef[1])
505
-
506
- if len(tdef) == 2:
507
- new_state = None
508
- else:
509
- new_state = cls._process_new_state(tdef[2],
510
- unprocessed, processed)
511
-
512
- tokens.append((rex, token, new_state))
513
- return tokens
514
-
515
- def process_tokendef(cls, name, tokendefs=None):
516
- """Preprocess a dictionary of token definitions."""
517
- processed = cls._all_tokens[name] = {}
518
- tokendefs = tokendefs or cls.tokens[name]
519
- for state in list(tokendefs):
520
- cls._process_state(tokendefs, processed, state)
521
- return processed
522
-
523
- def get_tokendefs(cls):
524
- """
525
- Merge tokens from superclasses in MRO order, returning a single tokendef
526
- dictionary.
527
-
528
- Any state that is not defined by a subclass will be inherited
529
- automatically. States that *are* defined by subclasses will, by
530
- default, override that state in the superclass. If a subclass wishes to
531
- inherit definitions from a superclass, it can use the special value
532
- "inherit", which will cause the superclass' state definition to be
533
- included at that point in the state.
534
- """
535
- tokens = {}
536
- inheritable = {}
537
- for c in cls.__mro__:
538
- toks = c.__dict__.get('tokens', {})
539
-
540
- for state, items in toks.items():
541
- curitems = tokens.get(state)
542
- if curitems is None:
543
- # N.b. because this is assigned by reference, sufficiently
544
- # deep hierarchies are processed incrementally (e.g. for
545
- # A(B), B(C), C(RegexLexer), B will be premodified so X(B)
546
- # will not see any inherits in B).
547
- tokens[state] = items
548
- try:
549
- inherit_ndx = items.index(inherit)
550
- except ValueError:
551
- continue
552
- inheritable[state] = inherit_ndx
553
- continue
554
-
555
- inherit_ndx = inheritable.pop(state, None)
556
- if inherit_ndx is None:
557
- continue
558
-
559
- # Replace the "inherit" value with the items
560
- curitems[inherit_ndx:inherit_ndx+1] = items
561
- try:
562
- # N.b. this is the index in items (that is, the superclass
563
- # copy), so offset required when storing below.
564
- new_inh_ndx = items.index(inherit)
565
- except ValueError:
566
- pass
567
- else:
568
- inheritable[state] = inherit_ndx + new_inh_ndx
569
-
570
- return tokens
571
-
572
- def __call__(cls, *args, **kwds):
573
- """Instantiate cls after preprocessing its token definitions."""
574
- if '_tokens' not in cls.__dict__:
575
- cls._all_tokens = {}
576
- cls._tmpname = 0
577
- if hasattr(cls, 'token_variants') and cls.token_variants:
578
- # don't process yet
579
- pass
580
- else:
581
- cls._tokens = cls.process_tokendef('', cls.get_tokendefs())
582
-
583
- return type.__call__(cls, *args, **kwds)
584
-
585
-
586
- class RegexLexer(Lexer, metaclass=RegexLexerMeta):
587
- """
588
- Base for simple stateful regular expression-based lexers.
589
- Simplifies the lexing process so that you need only
590
- provide a list of states and regular expressions.
591
- """
592
-
593
- #: Flags for compiling the regular expressions.
594
- #: Defaults to MULTILINE.
595
- flags = re.MULTILINE
596
-
597
- #: At all time there is a stack of states. Initially, the stack contains
598
- #: a single state 'root'. The top of the stack is called "the current state".
599
- #:
600
- #: Dict of ``{'state': [(regex, tokentype, new_state), ...], ...}``
601
- #:
602
- #: ``new_state`` can be omitted to signify no state transition.
603
- #: If ``new_state`` is a string, it is pushed on the stack. This ensure
604
- #: the new current state is ``new_state``.
605
- #: If ``new_state`` is a tuple of strings, all of those strings are pushed
606
- #: on the stack and the current state will be the last element of the list.
607
- #: ``new_state`` can also be ``combined('state1', 'state2', ...)``
608
- #: to signify a new, anonymous state combined from the rules of two
609
- #: or more existing ones.
610
- #: Furthermore, it can be '#pop' to signify going back one step in
611
- #: the state stack, or '#push' to push the current state on the stack
612
- #: again. Note that if you push while in a combined state, the combined
613
- #: state itself is pushed, and not only the state in which the rule is
614
- #: defined.
615
- #:
616
- #: The tuple can also be replaced with ``include('state')``, in which
617
- #: case the rules from the state named by the string are included in the
618
- #: current one.
619
- tokens = {}
620
-
621
- def get_tokens_unprocessed(self, text, stack=('root',)):
622
- """
623
- Split ``text`` into (tokentype, text) pairs.
624
-
625
- ``stack`` is the initial stack (default: ``['root']``)
626
- """
627
- pos = 0
628
- tokendefs = self._tokens
629
- statestack = list(stack)
630
- statetokens = tokendefs[statestack[-1]]
631
- while 1:
632
- for rexmatch, action, new_state in statetokens:
633
- m = rexmatch(text, pos)
634
- if m:
635
- if action is not None:
636
- if type(action) is _TokenType:
637
- yield pos, action, m.group()
638
- else:
639
- yield from action(self, m)
640
- pos = m.end()
641
- if new_state is not None:
642
- # state transition
643
- if isinstance(new_state, tuple):
644
- for state in new_state:
645
- if state == '#pop':
646
- if len(statestack) > 1:
647
- statestack.pop()
648
- elif state == '#push':
649
- statestack.append(statestack[-1])
650
- else:
651
- statestack.append(state)
652
- elif isinstance(new_state, int):
653
- # pop, but keep at least one state on the stack
654
- # (random code leading to unexpected pops should
655
- # not allow exceptions)
656
- if abs(new_state) >= len(statestack):
657
- del statestack[1:]
658
- else:
659
- del statestack[new_state:]
660
- elif new_state == '#push':
661
- statestack.append(statestack[-1])
662
- else:
663
- assert False, "wrong state def: %r" % new_state
664
- statetokens = tokendefs[statestack[-1]]
665
- break
666
- else:
667
- # We are here only if all state tokens have been considered
668
- # and there was not a match on any of them.
669
- try:
670
- if text[pos] == '\n':
671
- # at EOL, reset state to "root"
672
- statestack = ['root']
673
- statetokens = tokendefs['root']
674
- yield pos, Whitespace, '\n'
675
- pos += 1
676
- continue
677
- yield pos, Error, text[pos]
678
- pos += 1
679
- except IndexError:
680
- break
681
-
682
-
683
- class LexerContext:
684
- """
685
- A helper object that holds lexer position data.
686
- """
687
-
688
- def __init__(self, text, pos, stack=None, end=None):
689
- self.text = text
690
- self.pos = pos
691
- self.end = end or len(text) # end=0 not supported ;-)
692
- self.stack = stack or ['root']
693
-
694
- def __repr__(self):
695
- return 'LexerContext(%r, %r, %r)' % (
696
- self.text, self.pos, self.stack)
697
-
698
-
699
- class ExtendedRegexLexer(RegexLexer):
700
- """
701
- A RegexLexer that uses a context object to store its state.
702
- """
703
-
704
- def get_tokens_unprocessed(self, text=None, context=None):
705
- """
706
- Split ``text`` into (tokentype, text) pairs.
707
- If ``context`` is given, use this lexer context instead.
708
- """
709
- tokendefs = self._tokens
710
- if not context:
711
- ctx = LexerContext(text, 0)
712
- statetokens = tokendefs['root']
713
- else:
714
- ctx = context
715
- statetokens = tokendefs[ctx.stack[-1]]
716
- text = ctx.text
717
- while 1:
718
- for rexmatch, action, new_state in statetokens:
719
- m = rexmatch(text, ctx.pos, ctx.end)
720
- if m:
721
- if action is not None:
722
- if type(action) is _TokenType:
723
- yield ctx.pos, action, m.group()
724
- ctx.pos = m.end()
725
- else:
726
- yield from action(self, m, ctx)
727
- if not new_state:
728
- # altered the state stack?
729
- statetokens = tokendefs[ctx.stack[-1]]
730
- # CAUTION: callback must set ctx.pos!
731
- if new_state is not None:
732
- # state transition
733
- if isinstance(new_state, tuple):
734
- for state in new_state:
735
- if state == '#pop':
736
- if len(ctx.stack) > 1:
737
- ctx.stack.pop()
738
- elif state == '#push':
739
- ctx.stack.append(ctx.stack[-1])
740
- else:
741
- ctx.stack.append(state)
742
- elif isinstance(new_state, int):
743
- # see RegexLexer for why this check is made
744
- if abs(new_state) >= len(ctx.stack):
745
- del ctx.stack[1:]
746
- else:
747
- del ctx.stack[new_state:]
748
- elif new_state == '#push':
749
- ctx.stack.append(ctx.stack[-1])
750
- else:
751
- assert False, "wrong state def: %r" % new_state
752
- statetokens = tokendefs[ctx.stack[-1]]
753
- break
754
- else:
755
- try:
756
- if ctx.pos >= ctx.end:
757
- break
758
- if text[ctx.pos] == '\n':
759
- # at EOL, reset state to "root"
760
- ctx.stack = ['root']
761
- statetokens = tokendefs['root']
762
- yield ctx.pos, Text, '\n'
763
- ctx.pos += 1
764
- continue
765
- yield ctx.pos, Error, text[ctx.pos]
766
- ctx.pos += 1
767
- except IndexError:
768
- break
769
-
770
-
771
- def do_insertions(insertions, tokens):
772
- """
773
- Helper for lexers which must combine the results of several
774
- sublexers.
775
-
776
- ``insertions`` is a list of ``(index, itokens)`` pairs.
777
- Each ``itokens`` iterable should be inserted at position
778
- ``index`` into the token stream given by the ``tokens``
779
- argument.
780
-
781
- The result is a combined token stream.
782
-
783
- TODO: clean up the code here.
784
- """
785
- insertions = iter(insertions)
786
- try:
787
- index, itokens = next(insertions)
788
- except StopIteration:
789
- # no insertions
790
- yield from tokens
791
- return
792
-
793
- realpos = None
794
- insleft = True
795
-
796
- # iterate over the token stream where we want to insert
797
- # the tokens from the insertion list.
798
- for i, t, v in tokens:
799
- # first iteration. store the position of first item
800
- if realpos is None:
801
- realpos = i
802
- oldi = 0
803
- while insleft and i + len(v) >= index:
804
- tmpval = v[oldi:index - i]
805
- if tmpval:
806
- yield realpos, t, tmpval
807
- realpos += len(tmpval)
808
- for it_index, it_token, it_value in itokens:
809
- yield realpos, it_token, it_value
810
- realpos += len(it_value)
811
- oldi = index - i
812
- try:
813
- index, itokens = next(insertions)
814
- except StopIteration:
815
- insleft = False
816
- break # not strictly necessary
817
- if oldi < len(v):
818
- yield realpos, t, v[oldi:]
819
- realpos += len(v) - oldi
820
-
821
- # leftover tokens
822
- while insleft:
823
- # no normal tokens, set realpos to zero
824
- realpos = realpos or 0
825
- for p, t, v in itokens:
826
- yield realpos, t, v
827
- realpos += len(v)
828
- try:
829
- index, itokens = next(insertions)
830
- except StopIteration:
831
- insleft = False
832
- break # not strictly necessary
833
-
834
-
835
- class ProfilingRegexLexerMeta(RegexLexerMeta):
836
- """Metaclass for ProfilingRegexLexer, collects regex timing info."""
837
-
838
- def _process_regex(cls, regex, rflags, state):
839
- if isinstance(regex, words):
840
- rex = regex_opt(regex.words, prefix=regex.prefix,
841
- suffix=regex.suffix)
842
- else:
843
- rex = regex
844
- compiled = re.compile(rex, rflags)
845
-
846
- def match_func(text, pos, endpos=sys.maxsize):
847
- info = cls._prof_data[-1].setdefault((state, rex), [0, 0.0])
848
- t0 = time.time()
849
- res = compiled.match(text, pos, endpos)
850
- t1 = time.time()
851
- info[0] += 1
852
- info[1] += t1 - t0
853
- return res
854
- return match_func
855
-
856
-
857
- class ProfilingRegexLexer(RegexLexer, metaclass=ProfilingRegexLexerMeta):
858
- """Drop-in replacement for RegexLexer that does profiling of its regexes."""
859
-
860
- _prof_data = []
861
- _prof_sort_index = 4 # defaults to time per call
862
-
863
- def get_tokens_unprocessed(self, text, stack=('root',)):
864
- # this needs to be a stack, since using(this) will produce nested calls
865
- self.__class__._prof_data.append({})
866
- yield from RegexLexer.get_tokens_unprocessed(self, text, stack)
867
- rawdata = self.__class__._prof_data.pop()
868
- data = sorted(((s, repr(r).strip('u\'').replace('\\\\', '\\')[:65],
869
- n, 1000 * t, 1000 * t / n)
870
- for ((s, r), (n, t)) in rawdata.items()),
871
- key=lambda x: x[self._prof_sort_index],
872
- reverse=True)
873
- sum_total = sum(x[3] for x in data)
874
-
875
- print()
876
- print('Profiling result for %s lexing %d chars in %.3f ms' %
877
- (self.__class__.__name__, len(text), sum_total))
878
- print('=' * 110)
879
- print('%-20s %-64s ncalls tottime percall' % ('state', 'regex'))
880
- print('-' * 110)
881
- for d in data:
882
- print('%-20s %-65s %5d %8.4f %8.4f' % d)
883
- print('=' * 110)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/rich/region.py DELETED
@@ -1,10 +0,0 @@
1
- from typing import NamedTuple
2
-
3
-
4
- class Region(NamedTuple):
5
- """Defines a rectangular region of the screen."""
6
-
7
- x: int
8
- y: int
9
- width: int
10
- height: int
 
 
 
 
 
 
 
 
 
 
 
spaces/Baishali/Pneumonia-Detection/README.md DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- title: Pneumonia Detection
3
- emoji: 📈
4
- colorFrom: indigo
5
- colorTo: indigo
6
- sdk: gradio
7
- app_file: app.py
8
- pinned: false
9
- ---
10
- # Configuration
11
- `title`: _string_
12
- Display title for the Space
13
- `emoji`: _string_
14
- Space emoji (emoji-only character allowed)
15
- `colorFrom`: _string_
16
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
17
- `colorTo`: _string_
18
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
19
- `sdk`: _string_
20
- Can be either `gradio` or `streamlit`
21
- `app_file`: _string_
22
- Path to your main application file (which contains either `gradio` or `streamlit` Python code).
23
- Path is relative to the root of the repository.
24
- `pinned`: _boolean_
25
- Whether the Space stays on top of your list.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Bart92/RVC_HF/lib/uvr5_pack/lib_v5/nets_33966KB.py DELETED
@@ -1,122 +0,0 @@
1
- import torch
2
- from torch import nn
3
- import torch.nn.functional as F
4
-
5
- from . import layers_33966KB as layers
6
-
7
-
8
- class BaseASPPNet(nn.Module):
9
- def __init__(self, nin, ch, dilations=(4, 8, 16, 32)):
10
- super(BaseASPPNet, self).__init__()
11
- self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
12
- self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
13
- self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
14
- self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
15
-
16
- self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
17
-
18
- self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
19
- self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
20
- self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
21
- self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
22
-
23
- def __call__(self, x):
24
- h, e1 = self.enc1(x)
25
- h, e2 = self.enc2(h)
26
- h, e3 = self.enc3(h)
27
- h, e4 = self.enc4(h)
28
-
29
- h = self.aspp(h)
30
-
31
- h = self.dec4(h, e4)
32
- h = self.dec3(h, e3)
33
- h = self.dec2(h, e2)
34
- h = self.dec1(h, e1)
35
-
36
- return h
37
-
38
-
39
- class CascadedASPPNet(nn.Module):
40
- def __init__(self, n_fft):
41
- super(CascadedASPPNet, self).__init__()
42
- self.stg1_low_band_net = BaseASPPNet(2, 16)
43
- self.stg1_high_band_net = BaseASPPNet(2, 16)
44
-
45
- self.stg2_bridge = layers.Conv2DBNActiv(18, 8, 1, 1, 0)
46
- self.stg2_full_band_net = BaseASPPNet(8, 16)
47
-
48
- self.stg3_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
49
- self.stg3_full_band_net = BaseASPPNet(16, 32)
50
-
51
- self.out = nn.Conv2d(32, 2, 1, bias=False)
52
- self.aux1_out = nn.Conv2d(16, 2, 1, bias=False)
53
- self.aux2_out = nn.Conv2d(16, 2, 1, bias=False)
54
-
55
- self.max_bin = n_fft // 2
56
- self.output_bin = n_fft // 2 + 1
57
-
58
- self.offset = 128
59
-
60
- def forward(self, x, aggressiveness=None):
61
- mix = x.detach()
62
- x = x.clone()
63
-
64
- x = x[:, :, : self.max_bin]
65
-
66
- bandw = x.size()[2] // 2
67
- aux1 = torch.cat(
68
- [
69
- self.stg1_low_band_net(x[:, :, :bandw]),
70
- self.stg1_high_band_net(x[:, :, bandw:]),
71
- ],
72
- dim=2,
73
- )
74
-
75
- h = torch.cat([x, aux1], dim=1)
76
- aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
77
-
78
- h = torch.cat([x, aux1, aux2], dim=1)
79
- h = self.stg3_full_band_net(self.stg3_bridge(h))
80
-
81
- mask = torch.sigmoid(self.out(h))
82
- mask = F.pad(
83
- input=mask,
84
- pad=(0, 0, 0, self.output_bin - mask.size()[2]),
85
- mode="replicate",
86
- )
87
-
88
- if self.training:
89
- aux1 = torch.sigmoid(self.aux1_out(aux1))
90
- aux1 = F.pad(
91
- input=aux1,
92
- pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
93
- mode="replicate",
94
- )
95
- aux2 = torch.sigmoid(self.aux2_out(aux2))
96
- aux2 = F.pad(
97
- input=aux2,
98
- pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
99
- mode="replicate",
100
- )
101
- return mask * mix, aux1 * mix, aux2 * mix
102
- else:
103
- if aggressiveness:
104
- mask[:, :, : aggressiveness["split_bin"]] = torch.pow(
105
- mask[:, :, : aggressiveness["split_bin"]],
106
- 1 + aggressiveness["value"] / 3,
107
- )
108
- mask[:, :, aggressiveness["split_bin"] :] = torch.pow(
109
- mask[:, :, aggressiveness["split_bin"] :],
110
- 1 + aggressiveness["value"],
111
- )
112
-
113
- return mask * mix
114
-
115
- def predict(self, x_mag, aggressiveness=None):
116
- h = self.forward(x_mag, aggressiveness)
117
-
118
- if self.offset > 0:
119
- h = h[:, :, :, self.offset : -self.offset]
120
- assert h.size()[3] > 0
121
-
122
- return h
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/BartPoint/VoiceChange/infer_pack/attentions.py DELETED
@@ -1,417 +0,0 @@
1
- import copy
2
- import math
3
- import numpy as np
4
- import torch
5
- from torch import nn
6
- from torch.nn import functional as F
7
-
8
- from infer_pack import commons
9
- from infer_pack import modules
10
- from infer_pack.modules import LayerNorm
11
-
12
-
13
- class Encoder(nn.Module):
14
- def __init__(
15
- self,
16
- hidden_channels,
17
- filter_channels,
18
- n_heads,
19
- n_layers,
20
- kernel_size=1,
21
- p_dropout=0.0,
22
- window_size=10,
23
- **kwargs
24
- ):
25
- super().__init__()
26
- self.hidden_channels = hidden_channels
27
- self.filter_channels = filter_channels
28
- self.n_heads = n_heads
29
- self.n_layers = n_layers
30
- self.kernel_size = kernel_size
31
- self.p_dropout = p_dropout
32
- self.window_size = window_size
33
-
34
- self.drop = nn.Dropout(p_dropout)
35
- self.attn_layers = nn.ModuleList()
36
- self.norm_layers_1 = nn.ModuleList()
37
- self.ffn_layers = nn.ModuleList()
38
- self.norm_layers_2 = nn.ModuleList()
39
- for i in range(self.n_layers):
40
- self.attn_layers.append(
41
- MultiHeadAttention(
42
- hidden_channels,
43
- hidden_channels,
44
- n_heads,
45
- p_dropout=p_dropout,
46
- window_size=window_size,
47
- )
48
- )
49
- self.norm_layers_1.append(LayerNorm(hidden_channels))
50
- self.ffn_layers.append(
51
- FFN(
52
- hidden_channels,
53
- hidden_channels,
54
- filter_channels,
55
- kernel_size,
56
- p_dropout=p_dropout,
57
- )
58
- )
59
- self.norm_layers_2.append(LayerNorm(hidden_channels))
60
-
61
- def forward(self, x, x_mask):
62
- attn_mask = x_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
63
- x = x * x_mask
64
- for i in range(self.n_layers):
65
- y = self.attn_layers[i](x, x, attn_mask)
66
- y = self.drop(y)
67
- x = self.norm_layers_1[i](x + y)
68
-
69
- y = self.ffn_layers[i](x, x_mask)
70
- y = self.drop(y)
71
- x = self.norm_layers_2[i](x + y)
72
- x = x * x_mask
73
- return x
74
-
75
-
76
- class Decoder(nn.Module):
77
- def __init__(
78
- self,
79
- hidden_channels,
80
- filter_channels,
81
- n_heads,
82
- n_layers,
83
- kernel_size=1,
84
- p_dropout=0.0,
85
- proximal_bias=False,
86
- proximal_init=True,
87
- **kwargs
88
- ):
89
- super().__init__()
90
- self.hidden_channels = hidden_channels
91
- self.filter_channels = filter_channels
92
- self.n_heads = n_heads
93
- self.n_layers = n_layers
94
- self.kernel_size = kernel_size
95
- self.p_dropout = p_dropout
96
- self.proximal_bias = proximal_bias
97
- self.proximal_init = proximal_init
98
-
99
- self.drop = nn.Dropout(p_dropout)
100
- self.self_attn_layers = nn.ModuleList()
101
- self.norm_layers_0 = nn.ModuleList()
102
- self.encdec_attn_layers = nn.ModuleList()
103
- self.norm_layers_1 = nn.ModuleList()
104
- self.ffn_layers = nn.ModuleList()
105
- self.norm_layers_2 = nn.ModuleList()
106
- for i in range(self.n_layers):
107
- self.self_attn_layers.append(
108
- MultiHeadAttention(
109
- hidden_channels,
110
- hidden_channels,
111
- n_heads,
112
- p_dropout=p_dropout,
113
- proximal_bias=proximal_bias,
114
- proximal_init=proximal_init,
115
- )
116
- )
117
- self.norm_layers_0.append(LayerNorm(hidden_channels))
118
- self.encdec_attn_layers.append(
119
- MultiHeadAttention(
120
- hidden_channels, hidden_channels, n_heads, p_dropout=p_dropout
121
- )
122
- )
123
- self.norm_layers_1.append(LayerNorm(hidden_channels))
124
- self.ffn_layers.append(
125
- FFN(
126
- hidden_channels,
127
- hidden_channels,
128
- filter_channels,
129
- kernel_size,
130
- p_dropout=p_dropout,
131
- causal=True,
132
- )
133
- )
134
- self.norm_layers_2.append(LayerNorm(hidden_channels))
135
-
136
- def forward(self, x, x_mask, h, h_mask):
137
- """
138
- x: decoder input
139
- h: encoder output
140
- """
141
- self_attn_mask = commons.subsequent_mask(x_mask.size(2)).to(
142
- device=x.device, dtype=x.dtype
143
- )
144
- encdec_attn_mask = h_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
145
- x = x * x_mask
146
- for i in range(self.n_layers):
147
- y = self.self_attn_layers[i](x, x, self_attn_mask)
148
- y = self.drop(y)
149
- x = self.norm_layers_0[i](x + y)
150
-
151
- y = self.encdec_attn_layers[i](x, h, encdec_attn_mask)
152
- y = self.drop(y)
153
- x = self.norm_layers_1[i](x + y)
154
-
155
- y = self.ffn_layers[i](x, x_mask)
156
- y = self.drop(y)
157
- x = self.norm_layers_2[i](x + y)
158
- x = x * x_mask
159
- return x
160
-
161
-
162
- class MultiHeadAttention(nn.Module):
163
- def __init__(
164
- self,
165
- channels,
166
- out_channels,
167
- n_heads,
168
- p_dropout=0.0,
169
- window_size=None,
170
- heads_share=True,
171
- block_length=None,
172
- proximal_bias=False,
173
- proximal_init=False,
174
- ):
175
- super().__init__()
176
- assert channels % n_heads == 0
177
-
178
- self.channels = channels
179
- self.out_channels = out_channels
180
- self.n_heads = n_heads
181
- self.p_dropout = p_dropout
182
- self.window_size = window_size
183
- self.heads_share = heads_share
184
- self.block_length = block_length
185
- self.proximal_bias = proximal_bias
186
- self.proximal_init = proximal_init
187
- self.attn = None
188
-
189
- self.k_channels = channels // n_heads
190
- self.conv_q = nn.Conv1d(channels, channels, 1)
191
- self.conv_k = nn.Conv1d(channels, channels, 1)
192
- self.conv_v = nn.Conv1d(channels, channels, 1)
193
- self.conv_o = nn.Conv1d(channels, out_channels, 1)
194
- self.drop = nn.Dropout(p_dropout)
195
-
196
- if window_size is not None:
197
- n_heads_rel = 1 if heads_share else n_heads
198
- rel_stddev = self.k_channels**-0.5
199
- self.emb_rel_k = nn.Parameter(
200
- torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels)
201
- * rel_stddev
202
- )
203
- self.emb_rel_v = nn.Parameter(
204
- torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels)
205
- * rel_stddev
206
- )
207
-
208
- nn.init.xavier_uniform_(self.conv_q.weight)
209
- nn.init.xavier_uniform_(self.conv_k.weight)
210
- nn.init.xavier_uniform_(self.conv_v.weight)
211
- if proximal_init:
212
- with torch.no_grad():
213
- self.conv_k.weight.copy_(self.conv_q.weight)
214
- self.conv_k.bias.copy_(self.conv_q.bias)
215
-
216
- def forward(self, x, c, attn_mask=None):
217
- q = self.conv_q(x)
218
- k = self.conv_k(c)
219
- v = self.conv_v(c)
220
-
221
- x, self.attn = self.attention(q, k, v, mask=attn_mask)
222
-
223
- x = self.conv_o(x)
224
- return x
225
-
226
- def attention(self, query, key, value, mask=None):
227
- # reshape [b, d, t] -> [b, n_h, t, d_k]
228
- b, d, t_s, t_t = (*key.size(), query.size(2))
229
- query = query.view(b, self.n_heads, self.k_channels, t_t).transpose(2, 3)
230
- key = key.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
231
- value = value.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
232
-
233
- scores = torch.matmul(query / math.sqrt(self.k_channels), key.transpose(-2, -1))
234
- if self.window_size is not None:
235
- assert (
236
- t_s == t_t
237
- ), "Relative attention is only available for self-attention."
238
- key_relative_embeddings = self._get_relative_embeddings(self.emb_rel_k, t_s)
239
- rel_logits = self._matmul_with_relative_keys(
240
- query / math.sqrt(self.k_channels), key_relative_embeddings
241
- )
242
- scores_local = self._relative_position_to_absolute_position(rel_logits)
243
- scores = scores + scores_local
244
- if self.proximal_bias:
245
- assert t_s == t_t, "Proximal bias is only available for self-attention."
246
- scores = scores + self._attention_bias_proximal(t_s).to(
247
- device=scores.device, dtype=scores.dtype
248
- )
249
- if mask is not None:
250
- scores = scores.masked_fill(mask == 0, -1e4)
251
- if self.block_length is not None:
252
- assert (
253
- t_s == t_t
254
- ), "Local attention is only available for self-attention."
255
- block_mask = (
256
- torch.ones_like(scores)
257
- .triu(-self.block_length)
258
- .tril(self.block_length)
259
- )
260
- scores = scores.masked_fill(block_mask == 0, -1e4)
261
- p_attn = F.softmax(scores, dim=-1) # [b, n_h, t_t, t_s]
262
- p_attn = self.drop(p_attn)
263
- output = torch.matmul(p_attn, value)
264
- if self.window_size is not None:
265
- relative_weights = self._absolute_position_to_relative_position(p_attn)
266
- value_relative_embeddings = self._get_relative_embeddings(
267
- self.emb_rel_v, t_s
268
- )
269
- output = output + self._matmul_with_relative_values(
270
- relative_weights, value_relative_embeddings
271
- )
272
- output = (
273
- output.transpose(2, 3).contiguous().view(b, d, t_t)
274
- ) # [b, n_h, t_t, d_k] -> [b, d, t_t]
275
- return output, p_attn
276
-
277
- def _matmul_with_relative_values(self, x, y):
278
- """
279
- x: [b, h, l, m]
280
- y: [h or 1, m, d]
281
- ret: [b, h, l, d]
282
- """
283
- ret = torch.matmul(x, y.unsqueeze(0))
284
- return ret
285
-
286
- def _matmul_with_relative_keys(self, x, y):
287
- """
288
- x: [b, h, l, d]
289
- y: [h or 1, m, d]
290
- ret: [b, h, l, m]
291
- """
292
- ret = torch.matmul(x, y.unsqueeze(0).transpose(-2, -1))
293
- return ret
294
-
295
- def _get_relative_embeddings(self, relative_embeddings, length):
296
- max_relative_position = 2 * self.window_size + 1
297
- # Pad first before slice to avoid using cond ops.
298
- pad_length = max(length - (self.window_size + 1), 0)
299
- slice_start_position = max((self.window_size + 1) - length, 0)
300
- slice_end_position = slice_start_position + 2 * length - 1
301
- if pad_length > 0:
302
- padded_relative_embeddings = F.pad(
303
- relative_embeddings,
304
- commons.convert_pad_shape([[0, 0], [pad_length, pad_length], [0, 0]]),
305
- )
306
- else:
307
- padded_relative_embeddings = relative_embeddings
308
- used_relative_embeddings = padded_relative_embeddings[
309
- :, slice_start_position:slice_end_position
310
- ]
311
- return used_relative_embeddings
312
-
313
- def _relative_position_to_absolute_position(self, x):
314
- """
315
- x: [b, h, l, 2*l-1]
316
- ret: [b, h, l, l]
317
- """
318
- batch, heads, length, _ = x.size()
319
- # Concat columns of pad to shift from relative to absolute indexing.
320
- x = F.pad(x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, 1]]))
321
-
322
- # Concat extra elements so to add up to shape (len+1, 2*len-1).
323
- x_flat = x.view([batch, heads, length * 2 * length])
324
- x_flat = F.pad(
325
- x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [0, length - 1]])
326
- )
327
-
328
- # Reshape and slice out the padded elements.
329
- x_final = x_flat.view([batch, heads, length + 1, 2 * length - 1])[
330
- :, :, :length, length - 1 :
331
- ]
332
- return x_final
333
-
334
- def _absolute_position_to_relative_position(self, x):
335
- """
336
- x: [b, h, l, l]
337
- ret: [b, h, l, 2*l-1]
338
- """
339
- batch, heads, length, _ = x.size()
340
- # padd along column
341
- x = F.pad(
342
- x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, length - 1]])
343
- )
344
- x_flat = x.view([batch, heads, length**2 + length * (length - 1)])
345
- # add 0's in the beginning that will skew the elements after reshape
346
- x_flat = F.pad(x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [length, 0]]))
347
- x_final = x_flat.view([batch, heads, length, 2 * length])[:, :, :, 1:]
348
- return x_final
349
-
350
- def _attention_bias_proximal(self, length):
351
- """Bias for self-attention to encourage attention to close positions.
352
- Args:
353
- length: an integer scalar.
354
- Returns:
355
- a Tensor with shape [1, 1, length, length]
356
- """
357
- r = torch.arange(length, dtype=torch.float32)
358
- diff = torch.unsqueeze(r, 0) - torch.unsqueeze(r, 1)
359
- return torch.unsqueeze(torch.unsqueeze(-torch.log1p(torch.abs(diff)), 0), 0)
360
-
361
-
362
- class FFN(nn.Module):
363
- def __init__(
364
- self,
365
- in_channels,
366
- out_channels,
367
- filter_channels,
368
- kernel_size,
369
- p_dropout=0.0,
370
- activation=None,
371
- causal=False,
372
- ):
373
- super().__init__()
374
- self.in_channels = in_channels
375
- self.out_channels = out_channels
376
- self.filter_channels = filter_channels
377
- self.kernel_size = kernel_size
378
- self.p_dropout = p_dropout
379
- self.activation = activation
380
- self.causal = causal
381
-
382
- if causal:
383
- self.padding = self._causal_padding
384
- else:
385
- self.padding = self._same_padding
386
-
387
- self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size)
388
- self.conv_2 = nn.Conv1d(filter_channels, out_channels, kernel_size)
389
- self.drop = nn.Dropout(p_dropout)
390
-
391
- def forward(self, x, x_mask):
392
- x = self.conv_1(self.padding(x * x_mask))
393
- if self.activation == "gelu":
394
- x = x * torch.sigmoid(1.702 * x)
395
- else:
396
- x = torch.relu(x)
397
- x = self.drop(x)
398
- x = self.conv_2(self.padding(x * x_mask))
399
- return x * x_mask
400
-
401
- def _causal_padding(self, x):
402
- if self.kernel_size == 1:
403
- return x
404
- pad_l = self.kernel_size - 1
405
- pad_r = 0
406
- padding = [[0, 0], [0, 0], [pad_l, pad_r]]
407
- x = F.pad(x, commons.convert_pad_shape(padding))
408
- return x
409
-
410
- def _same_padding(self, x):
411
- if self.kernel_size == 1:
412
- return x
413
- pad_l = (self.kernel_size - 1) // 2
414
- pad_r = self.kernel_size // 2
415
- padding = [[0, 0], [0, 0], [pad_l, pad_r]]
416
- x = F.pad(x, commons.convert_pad_shape(padding))
417
- return x
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Benson/text-generation/Examples/Colinas De Acero Mod Apk 5.2.0 An1.md DELETED
@@ -1,70 +0,0 @@
1
-
2
- <h1>Colinas de acero Mod APK 5.2.0 AN1: Un divertido y lleno de acción del juego del tanque</h1>
3
- <p>Si usted está buscando un juego de tanques que es divertido, lleno de acción, y fácil de jugar, entonces usted debe probar Hills of Steel Mod APK 5.2.0 AN1. Esta es una versión modificada del popular juego de tanques Hills of Steel, que tiene más de 50 millones de descargas en Google Play Store. En este juego, puedes controlar varios tanques y utilizarlos para destruir a tus enemigos, mientras que también recoger monedas y mejorar tus armas. También puedes jugar diferentes modos, como Aventura, PvP, Boss Rush y Eventos, para poner a prueba tus habilidades y divertirte más. </p>
4
- <p>En este artículo, le diremos todo lo que necesita saber sobre Hills of Steel Mod APK 5.2.0 AN1, incluyendo sus características, cómo descargar e instalar, consejos y trucos para jugarlo, y sus pros y contras. Al final de este artículo, usted será capaz de decidir si este juego vale la pena jugar o no. </p>
5
- <h2>colinas de acero mod apk 5.2.0 an1</h2><br /><p><b><b>Download</b> &#9658; <a href="https://bltlly.com/2v6MgM">https://bltlly.com/2v6MgM</a></b></p><br /><br />
6
- <h2>Características de Hills of Steel Mod APK 5.2.0 AN1</h2>
7
- <p>Una de las principales razones por las que debe jugar Hills of Steel Mod APK 5.2.0 AN1 es porque tiene algunas características sorprendentes que hacen que el juego más agradable y gratificante. Estas son algunas de las características que puedes esperar de esta versión modificada:</p>
8
- <h3>Monedas ilimitadas</h3>
9
- <p>Las monedas son la moneda principal en Hills of Steel, que puedes usar para comprar nuevos tanques, mejorar tus armas y desbloquear nuevos modos. Sin embargo, ganar monedas en el juego original puede ser bastante lento y tedioso, especialmente si desea obtener los mejores tanques y armas disponibles. Es por eso que Hills of Steel Mod APK 5.2.0 AN1 le da monedas ilimitadas, por lo que puede comprar cualquier cosa que desee sin preocuparse por quedarse sin dinero. </p>
10
- <h3>Desbloquear todos los tanques</h3>
11
-
12
- <p>Sin embargo, no todos los tanques están disponibles desde el principio en el juego original. Tienes que desbloquearlos completando ciertos niveles o logros o gastando monedas o dinero real. Esto puede ser frustrante si quieres probar diferentes tanques y ver cuál se adapta mejor a tu estilo de juego. </p>
13
- <p>Es por eso que Hills of Steel Mod APK 5.2.0 AN1 desbloquea todos los tanques para usted desde el principio, para que pueda experimentar con ellos y encontrar su favorito. También puede personalizar sus tanques cambiando sus colores, pieles y pegatinas, para que se vean más frescos y únicos. </p>
14
- <h3>No hay anuncios</h3>
15
- <p>Otra cosa molesta sobre el juego original es que tiene un montón de anuncios que aparecen de vez en cuando, interrumpiendo su juego y perdiendo el tiempo. Estos anuncios pueden ser muy perturbadores y molestos, especialmente si estás en medio de una batalla tensa o un nivel desafiante. </p>
16
- <p></p>
17
- <p>Es por eso que Hills of Steel Mod APK 5.2.0 AN1 elimina todos los anuncios del juego, para que pueda disfrutar del juego sin interrupciones ni distracciones. Puedes jugar el juego todo el tiempo que quieras, sin tener que ver ningún anuncio o pagar ningún dinero para deshacerse de ellos. </p>
18
- <h2>Cómo descargar e instalar colinas de acero Mod APK 5.2.0 AN1</h2>
19
- <p>Ahora que conoce las características de Hills of Steel Mod APK 5.2.0 AN1, es posible que se pregunte cómo descargar e instalar en su dispositivo. No te preocupes, es muy fácil y sencillo. Solo sigue estos pasos:</p>
20
- <h3>Paso 1: Descargar el archivo apk mod de una fuente de confianza</h3>
21
- <p>Lo primero que tienes que hacer es descargar el archivo apk mod de una fuente de confianza, como [AN1.com]. Este es un sitio web que proporciona versiones modificadas de varios juegos y aplicaciones, incluyendo Hills of Steel Mod APK 5.2.0 AN1. Puede descargar el archivo haciendo clic en el botón de descarga en el sitio web, o escaneando el código QR con su dispositivo. </p>
22
- <h3>Paso 2: Habilitar fuentes desconocidas en el dispositivo</h3>
23
-
24
- <h3>Paso 3: Instalar el archivo apk mod y lanzar el juego</h3>
25
- <p>Lo último que tienes que hacer es instalar el archivo apk mod y lanzar el juego. Para ello, busque el archivo en el almacenamiento del dispositivo, toque en él y siga las instrucciones en la pantalla. Una vez completada la instalación, puedes iniciar el juego tocando su icono en la pantalla de inicio o en el cajón de la aplicación. </p>
26
- <p>Felicidades! Usted ha descargado e instalado con éxito Hills of Steel Mod APK 5.2.0 AN1 en su dispositivo. Ahora puedes disfrutar del juego con todas sus características y beneficios. </p>
27
- <h2>Consejos y trucos para jugar colinas de acero Mod APK 5.2.0 AN1</h2>
28
- <p>Hills of Steel Mod APK 5.2.0 AN1 es un juego de tanques divertido y lleno de acción, pero también puede ser difícil y difícil a veces. Por eso hemos preparado algunos consejos y trucos para jugarlo, que te ayudarán a mejorar tus habilidades y divertirte más. </p>
29
- <h3>Consejo 1: Aprende la física y los controles de cada tanque</h3>
30
- <p>Una de las cosas más importantes que hacer en Hills of Steel Mod APK 5.2.0 AN1 es aprender la física y los controles de cada tanque que se utiliza. Cada tanque tiene su propio peso, velocidad, aceleración, maniobrabilidad, potencia de fuego, armadura y habilidad especial, que afectan cómo se comporta en diferentes terrenos y situaciones. </p>
31
- <p>Por ejemplo, algunos tanques son más rápidos y ligeros que otros, lo que los hace más fáciles de mover y esquivar el fuego enemigo, pero también más vulnerables a los daños y volteos. Algunos tanques tienen armas más poderosas que otros, lo que los hace más eficaces para destruir enemigos y obstáculos, pero también más propensos al sobrecalentamiento y recarga. </p>
32
- <p>Algunos tanques tienen habilidades especiales que pueden darles una ventaja en ciertos escenarios, como lanzar cohetes, lanzar minas, congelar enemigos, etc., pero también tienen tiempos de reutilización o limitaciones que les impiden ser utilizados con demasiada frecuencia o demasiado imprudentemente. </p>
33
-
34
- <h3>Consejo 2: Usa el terreno y los obstáculos para tu ventaja</h3>
35
- <p>Otra cosa importante que hacer en Hills of Steel Mod APK 5.2.0 AN1 es utilizar el terreno y los obstáculos a su ventaja. El juego tiene varios mapas que tienen diferentes características, como colinas, valles, puentes, rampas, rocas, árboles, edificios, etc., que pueden afectar el movimiento y el rendimiento de su tanque. Por lo tanto, es necesario utilizar el terreno y los obstáculos a su ventaja, mediante su uso como cobertura, apalancamiento, o trampas. Por ejemplo, puedes esconderte detrás de rocas o árboles para evitar el fuego enemigo, o usarlos para bloquear su camino o visión. También puedes usar colinas o rampas para ganar velocidad o altura, o para lanzarte al aire y aterrizar sobre tus enemigos. También puedes usar puentes o edificios para cruzar brechas o emboscar a tus enemigos desde arriba. Sin embargo, también debe tener cuidado de no dejar que el terreno y los obstáculos trabajen en su contra, evitándolos cuando son peligrosos o perjudiciales. Por ejemplo, debes evitar caer en valles o agua, ya que pueden ralentizarte o dañar tu tanque. También debes evitar golpear rocas o árboles demasiado fuerte, ya que pueden voltear tu tanque o romper tus armas. También debes evitar quedarte atrapado en espacios o esquinas estrechas, ya que pueden convertirte en un objetivo fácil para tus enemigos. </p>
36
- <h3>Consejo 3: Mejora tus tanques y armas regularmente</h3>
37
- <p>El último consejo que tenemos para jugar Hills of Steel Mod APK 5.2.0 AN1 es actualizar sus tanques y armas con regularidad. A medida que avances en el juego, te enfrentarás a enemigos y niveles más desafiantes, lo que requerirá más potencia de fuego y durabilidad de tus tanques y armas. </p>
38
-
39
- <p>Sin embargo, también debes ser inteligente sobre cómo gastas tus monedas y qué tanques y armas mejoras. Usted debe dar prioridad a la mejora de los tanques y armas que se utilizan con mayor frecuencia o que se adapten mejor a su estilo de juego. También debe equilibrar la actualización de diferentes aspectos de sus tanques y armas, por lo que no descuidar ningún factor importante. Por ejemplo, no solo debes centrarte en mejorar el daño, sino también en el alcance y la precisión, para que puedas golpear a tus enemigos más fácilmente y desde una distancia segura. </p>
40
- <h2>Pros y contras de las colinas de acero Mod APK 5.2.0 AN1</h2>
41
- <p>Hills of Steel Mod APK 5.2.0 AN1 es un gran juego que tiene muchos pros y contras que usted debe considerar antes de jugar. Estos son algunos de los pros y contras que hemos encontrado:</p>
42
- <h3>Pro 1: juego divertido y adictivo</h3>
43
- <p>Uno de los principales pros de Hills of Steel Mod APK 5.2.0 AN1 es que tiene un juego divertido y adictivo que te mantendrá entretenido durante horas. El juego es simple de jugar pero difícil de dominar, ya que requiere habilidad, estrategia y suerte para ganar. El juego también es muy satisfactorio y gratificante, ya que puedes ver a tus enemigos explotar en pedazos, recoger monedas y trofeos, y desbloquear nuevos tanques y modos. </p>
44
- <h3>Pro 2: Variedad de tanques y modos</h3>
45
- <p>Otro pro de Colinas de Acero Mod APK 5.2.0 AN1 es que tiene una variedad de tanques y modos que le dará más opciones y desafíos. El juego tiene más de 20 tanques que se puede elegir, cada uno con sus propias características y habilidades. El juego también tiene diferentes modos que puedes jugar, como Aventura, PvP, Boss Rush y Eventos, cada uno con sus propios objetivos y dificultades. </p>
46
- <h3>Pro 3: gráficos suaves y efectos de sonido</h3>
47
-
48
- <h3>Con 1: Niveles repetitivos y enemigos</h3>
49
- <p>Uno de los principales contras de Hills of Steel Mod APK 5.2.0 AN1 es que tiene niveles repetitivos y enemigos que pueden hacer que el juego aburrido y monótono después de un tiempo. El juego tiene un número limitado de mapas y escenarios que se repiten una y otra vez, con poca variación o innovación. El juego también tiene un número limitado de enemigos y jefes que son fáciles de predecir y derrotar, sin sorpresas ni giros. </p>
50
- <h3>Con 2: Requiere conexión a Internet para algunas características</h3>
51
- <p>Otra estafa de Colinas de Acero Mod APK 5.2.0 AN1 es que requiere conexión a Internet para algunas características que son esenciales para el juego. El juego requiere conexión a Internet para jugar el modo PvP, que es uno de los modos más divertidos y competitivos del juego. El juego también requiere conexión a Internet para acceder al modo Eventos, que es uno de los modos más gratificantes y desafiantes del juego. El juego también requiere conexión a Internet para sincronizar su progreso y los datos con la nube, que es importante para guardar sus logros y monedas. </p>
52
- <h2>Conclusión</h2>
53
- <p>Hills of Steel Mod APK 5.2.0 AN1 es un divertido y lleno de acción juego de tanques que usted debe probar si usted está buscando un juego simple pero emocionante para jugar en su dispositivo. El juego tiene muchas características que lo hacen más agradable y gratificante, como monedas ilimitadas, desbloquear todos los tanques, y sin anuncios. El juego también tiene una variedad de tanques y modos que te dan más opciones y desafíos, como Aventura, PvP, Boss Rush y Eventos. El juego también tiene gráficos suaves y efectos de sonido que mejoran la experiencia de juego. </p>
54
- <p>Sin embargo, el juego también tiene algunos inconvenientes que debes tener en cuenta antes de jugarlo, como los niveles repetitivos y los enemigos que pueden hacer que el juego sea aburrido y monótono después de un tiempo. El juego también requiere conexión a Internet para algunas funciones que son esenciales para el juego, como el modo PvP, el modo Eventos y la sincronización en la nube. </p>
55
-
56
- <p>Esperamos que este artículo te haya ayudado a aprender todo lo que necesitas saber sobre Hills of Steel Mod APK 5.2.0 AN1, incluyendo sus características, cómo descargarlo e instalarlo, consejos y trucos para jugarlo, y sus pros y contras. Si tiene alguna pregunta o comentario, no dude en dejar un comentario a continuación. </p>
57
- <h2>Preguntas frecuentes</h2>
58
- <p>Aquí están algunas de las preguntas más frecuentes sobre Hills of Steel Mod APK 5.2.0 AN1:</p>
59
- <h3>Q: ¿Es seguro descargar e instalar Hills of Steel Mod APK 5.2.0 AN1? </h3>
60
- <p>A: Sí, Hills of Steel Mod APK 5.2.0 AN1 es seguro de descargar e instalar, siempre y cuando se descarga desde una fuente de confianza, como [AN1.com]. Este sitio web proporciona versiones modificadas de varios juegos y aplicaciones que son probados y verificados por su equipo de expertos. </p>
61
- <h3>Q: ¿Es Hills of Steel Mod APK 5.2.0 AN1 compatible con mi dispositivo? </h3>
62
- <p>A: Hills of Steel Mod APK 5.2.0 AN1 es compatible con la mayoría de los dispositivos Android que tienen Android 4.4 o versiones superiores instalados en ellos. Sin embargo, algunos dispositivos pueden tener problemas de compatibilidad o problemas de rendimiento debido a diferentes especificaciones o configuraciones. </p>
63
- <h3>Q: ¿Cómo puedo actualizar Hills of Steel Mod APK 5.2.0 AN1? </h3>
64
- <p>A: Puede actualizar Hills of Steel Mod APK 5.2.0 AN1 descargando la última versión de [AN1.com] e instalándolo sobre el existente en su dispositivo. Sin embargo, siempre debes hacer una copia de seguridad de tus datos antes de actualizar cualquier aplicación o juego, ya que puede haber algunos riesgos de perder tu progreso o monedas. </p>
65
- <h3>Q: ¿Cómo puedo contactar a los desarrolladores de Hills of Steel Mod APK 5.2.0 AN1? </h3>
66
- <p>A: Puede ponerse en contacto con los desarrolladores de Hills of Steel Mod APK 5.2.0 AN1 visitando su sitio web oficial [HillsOfSteel.com] o enviándoles un correo electrónico a [[email protected]]. También puedes seguirlos en sus cuentas de redes sociales, como Facebook, Twitter, Instagram, YouTube, etc., para obtener las últimas noticias y actualizaciones sobre sus juegos. </p>
67
-
68
- <p>A: Algunos otros juegos como Hills of Steel Mod APK 5.2.0 AN1 son Tank Stars Mod APK, War Machines Mod APK , y Tank Hero Mod APK. Estos son algunos de los mejores juegos de tanques que se puede jugar en su dispositivo, que tienen características similares y jugabilidad como Hills of Steel Mod APK 5.2.0 AN1. También puedes descargar estos juegos de [AN1.com] y disfrutarlos con sus versiones modificadas. </p> 64aa2da5cf<br />
69
- <br />
70
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/detectron2/evaluation/sem_seg_evaluation.py DELETED
@@ -1,163 +0,0 @@
1
- # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2
- import itertools
3
- import json
4
- import logging
5
- import numpy as np
6
- import os
7
- from collections import OrderedDict
8
- import PIL.Image as Image
9
- import pycocotools.mask as mask_util
10
- import torch
11
- from fvcore.common.file_io import PathManager
12
-
13
- from detectron2.data import DatasetCatalog, MetadataCatalog
14
- from detectron2.utils.comm import all_gather, is_main_process, synchronize
15
-
16
- from .evaluator import DatasetEvaluator
17
-
18
-
19
- class SemSegEvaluator(DatasetEvaluator):
20
- """
21
- Evaluate semantic segmentation
22
- """
23
-
24
- def __init__(self, dataset_name, distributed, num_classes, ignore_label=255, output_dir=None):
25
- """
26
- Args:
27
- dataset_name (str): name of the dataset to be evaluated.
28
- distributed (True): if True, will collect results from all ranks for evaluation.
29
- Otherwise, will evaluate the results in the current process.
30
- num_classes (int): number of classes
31
- ignore_label (int): value in semantic segmentation ground truth. Predictions for the
32
- corresponding pixels should be ignored.
33
- output_dir (str): an output directory to dump results.
34
- """
35
- self._dataset_name = dataset_name
36
- self._distributed = distributed
37
- self._output_dir = output_dir
38
- self._num_classes = num_classes
39
- self._ignore_label = ignore_label
40
- self._N = num_classes + 1
41
-
42
- self._cpu_device = torch.device("cpu")
43
- self._logger = logging.getLogger(__name__)
44
-
45
- self.input_file_to_gt_file = {
46
- dataset_record["file_name"]: dataset_record["sem_seg_file_name"]
47
- for dataset_record in DatasetCatalog.get(dataset_name)
48
- }
49
-
50
- meta = MetadataCatalog.get(dataset_name)
51
- # Dict that maps contiguous training ids to COCO category ids
52
- try:
53
- c2d = meta.stuff_dataset_id_to_contiguous_id
54
- self._contiguous_id_to_dataset_id = {v: k for k, v in c2d.items()}
55
- except AttributeError:
56
- self._contiguous_id_to_dataset_id = None
57
-
58
- def reset(self):
59
- self._conf_matrix = np.zeros((self._N, self._N), dtype=np.int64)
60
- self._predictions = []
61
-
62
- def process(self, inputs, outputs):
63
- """
64
- Args:
65
- inputs: the inputs to a model.
66
- It is a list of dicts. Each dict corresponds to an image and
67
- contains keys like "height", "width", "file_name".
68
- outputs: the outputs of a model. It is either list of semantic segmentation predictions
69
- (Tensor [H, W]) or list of dicts with key "sem_seg" that contains semantic
70
- segmentation prediction in the same format.
71
- """
72
- for input, output in zip(inputs, outputs):
73
- output = output["sem_seg"].argmax(dim=0).to(self._cpu_device)
74
- pred = np.array(output, dtype=np.int)
75
- with PathManager.open(self.input_file_to_gt_file[input["file_name"]], "rb") as f:
76
- gt = np.array(Image.open(f), dtype=np.int)
77
-
78
- gt[gt == self._ignore_label] = self._num_classes
79
-
80
- self._conf_matrix += np.bincount(
81
- self._N * pred.reshape(-1) + gt.reshape(-1), minlength=self._N ** 2
82
- ).reshape(self._N, self._N)
83
-
84
- self._predictions.extend(self.encode_json_sem_seg(pred, input["file_name"]))
85
-
86
- def evaluate(self):
87
- """
88
- Evaluates standard semantic segmentation metrics (http://cocodataset.org/#stuff-eval):
89
-
90
- * Mean intersection-over-union averaged across classes (mIoU)
91
- * Frequency Weighted IoU (fwIoU)
92
- * Mean pixel accuracy averaged across classes (mACC)
93
- * Pixel Accuracy (pACC)
94
- """
95
- if self._distributed:
96
- synchronize()
97
- conf_matrix_list = all_gather(self._conf_matrix)
98
- self._predictions = all_gather(self._predictions)
99
- self._predictions = list(itertools.chain(*self._predictions))
100
- if not is_main_process():
101
- return
102
-
103
- self._conf_matrix = np.zeros_like(self._conf_matrix)
104
- for conf_matrix in conf_matrix_list:
105
- self._conf_matrix += conf_matrix
106
-
107
- if self._output_dir:
108
- PathManager.mkdirs(self._output_dir)
109
- file_path = os.path.join(self._output_dir, "sem_seg_predictions.json")
110
- with PathManager.open(file_path, "w") as f:
111
- f.write(json.dumps(self._predictions))
112
-
113
- acc = np.zeros(self._num_classes, dtype=np.float)
114
- iou = np.zeros(self._num_classes, dtype=np.float)
115
- tp = self._conf_matrix.diagonal()[:-1].astype(np.float)
116
- pos_gt = np.sum(self._conf_matrix[:-1, :-1], axis=0).astype(np.float)
117
- class_weights = pos_gt / np.sum(pos_gt)
118
- pos_pred = np.sum(self._conf_matrix[:-1, :-1], axis=1).astype(np.float)
119
- acc_valid = pos_gt > 0
120
- acc[acc_valid] = tp[acc_valid] / pos_gt[acc_valid]
121
- iou_valid = (pos_gt + pos_pred) > 0
122
- union = pos_gt + pos_pred - tp
123
- iou[acc_valid] = tp[acc_valid] / union[acc_valid]
124
- macc = np.sum(acc) / np.sum(acc_valid)
125
- miou = np.sum(iou) / np.sum(iou_valid)
126
- fiou = np.sum(iou * class_weights)
127
- pacc = np.sum(tp) / np.sum(pos_gt)
128
-
129
- res = {}
130
- res["mIoU"] = 100 * miou
131
- res["fwIoU"] = 100 * fiou
132
- res["mACC"] = 100 * macc
133
- res["pACC"] = 100 * pacc
134
-
135
- if self._output_dir:
136
- file_path = os.path.join(self._output_dir, "sem_seg_evaluation.pth")
137
- with PathManager.open(file_path, "wb") as f:
138
- torch.save(res, f)
139
- results = OrderedDict({"sem_seg": res})
140
- self._logger.info(results)
141
- return results
142
-
143
- def encode_json_sem_seg(self, sem_seg, input_file_name):
144
- """
145
- Convert semantic segmentation to COCO stuff format with segments encoded as RLEs.
146
- See http://cocodataset.org/#format-results
147
- """
148
- json_list = []
149
- for label in np.unique(sem_seg):
150
- if self._contiguous_id_to_dataset_id is not None:
151
- assert (
152
- label in self._contiguous_id_to_dataset_id
153
- ), "Label {} is not in the metadata info for {}".format(label, self._dataset_name)
154
- dataset_id = self._contiguous_id_to_dataset_id[label]
155
- else:
156
- dataset_id = int(label)
157
- mask = (sem_seg == label).astype(np.uint8)
158
- mask_rle = mask_util.encode(np.array(mask[:, :, None], order="F"))[0]
159
- mask_rle["counts"] = mask_rle["counts"].decode("utf-8")
160
- json_list.append(
161
- {"file_name": input_file_name, "category_id": dataset_id, "segmentation": mask_rle}
162
- )
163
- return json_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/tests/test_rotated_boxes.py DELETED
@@ -1,590 +0,0 @@
1
- # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2
- from __future__ import absolute_import, division, print_function, unicode_literals
3
- import logging
4
- import math
5
- import random
6
- import unittest
7
- import torch
8
- from fvcore.common.benchmark import benchmark
9
-
10
- from detectron2.layers.rotated_boxes import pairwise_iou_rotated
11
- from detectron2.structures.boxes import Boxes
12
- from detectron2.structures.rotated_boxes import RotatedBoxes, pairwise_iou
13
-
14
- logger = logging.getLogger(__name__)
15
-
16
-
17
- class TestRotatedBoxesLayer(unittest.TestCase):
18
- def test_iou_0_dim_cpu(self):
19
- boxes1 = torch.rand(0, 5, dtype=torch.float32)
20
- boxes2 = torch.rand(10, 5, dtype=torch.float32)
21
- expected_ious = torch.zeros(0, 10, dtype=torch.float32)
22
- ious = pairwise_iou_rotated(boxes1, boxes2)
23
- self.assertTrue(torch.allclose(ious, expected_ious))
24
-
25
- boxes1 = torch.rand(10, 5, dtype=torch.float32)
26
- boxes2 = torch.rand(0, 5, dtype=torch.float32)
27
- expected_ious = torch.zeros(10, 0, dtype=torch.float32)
28
- ious = pairwise_iou_rotated(boxes1, boxes2)
29
- self.assertTrue(torch.allclose(ious, expected_ious))
30
-
31
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
32
- def test_iou_0_dim_cuda(self):
33
- boxes1 = torch.rand(0, 5, dtype=torch.float32)
34
- boxes2 = torch.rand(10, 5, dtype=torch.float32)
35
- expected_ious = torch.zeros(0, 10, dtype=torch.float32)
36
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
37
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
38
-
39
- boxes1 = torch.rand(10, 5, dtype=torch.float32)
40
- boxes2 = torch.rand(0, 5, dtype=torch.float32)
41
- expected_ious = torch.zeros(10, 0, dtype=torch.float32)
42
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
43
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
44
-
45
- def test_iou_half_overlap_cpu(self):
46
- boxes1 = torch.tensor([[0.5, 0.5, 1.0, 1.0, 0.0]], dtype=torch.float32)
47
- boxes2 = torch.tensor([[0.25, 0.5, 0.5, 1.0, 0.0]], dtype=torch.float32)
48
- expected_ious = torch.tensor([[0.5]], dtype=torch.float32)
49
- ious = pairwise_iou_rotated(boxes1, boxes2)
50
- self.assertTrue(torch.allclose(ious, expected_ious))
51
-
52
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
53
- def test_iou_half_overlap_cuda(self):
54
- boxes1 = torch.tensor([[0.5, 0.5, 1.0, 1.0, 0.0]], dtype=torch.float32)
55
- boxes2 = torch.tensor([[0.25, 0.5, 0.5, 1.0, 0.0]], dtype=torch.float32)
56
- expected_ious = torch.tensor([[0.5]], dtype=torch.float32)
57
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
58
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
59
-
60
- def test_iou_0_degree_cpu(self):
61
- boxes1 = torch.tensor(
62
- [[0.5, 0.5, 1.0, 1.0, 0.0], [0.5, 0.5, 1.0, 1.0, 0.0]], dtype=torch.float32
63
- )
64
- boxes2 = torch.tensor(
65
- [
66
- [0.5, 0.5, 1.0, 1.0, 0.0],
67
- [0.25, 0.5, 0.5, 1.0, 0.0],
68
- [0.5, 0.25, 1.0, 0.5, 0.0],
69
- [0.25, 0.25, 0.5, 0.5, 0.0],
70
- [0.75, 0.75, 0.5, 0.5, 0.0],
71
- [1.0, 1.0, 1.0, 1.0, 0.0],
72
- ],
73
- dtype=torch.float32,
74
- )
75
- expected_ious = torch.tensor(
76
- [
77
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
78
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
79
- ],
80
- dtype=torch.float32,
81
- )
82
- ious = pairwise_iou_rotated(boxes1, boxes2)
83
- self.assertTrue(torch.allclose(ious, expected_ious))
84
-
85
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
86
- def test_iou_0_degree_cuda(self):
87
- boxes1 = torch.tensor(
88
- [[0.5, 0.5, 1.0, 1.0, 0.0], [0.5, 0.5, 1.0, 1.0, 0.0]], dtype=torch.float32
89
- )
90
- boxes2 = torch.tensor(
91
- [
92
- [0.5, 0.5, 1.0, 1.0, 0.0],
93
- [0.25, 0.5, 0.5, 1.0, 0.0],
94
- [0.5, 0.25, 1.0, 0.5, 0.0],
95
- [0.25, 0.25, 0.5, 0.5, 0.0],
96
- [0.75, 0.75, 0.5, 0.5, 0.0],
97
- [1.0, 1.0, 1.0, 1.0, 0.0],
98
- ],
99
- dtype=torch.float32,
100
- )
101
- expected_ious = torch.tensor(
102
- [
103
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
104
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
105
- ],
106
- dtype=torch.float32,
107
- )
108
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
109
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
110
-
111
- def test_iou_45_degrees_cpu(self):
112
- boxes1 = torch.tensor(
113
- [
114
- [1, 1, math.sqrt(2), math.sqrt(2), 45],
115
- [1, 1, 2 * math.sqrt(2), 2 * math.sqrt(2), -45],
116
- ],
117
- dtype=torch.float32,
118
- )
119
- boxes2 = torch.tensor([[1, 1, 2, 2, 0]], dtype=torch.float32)
120
- expected_ious = torch.tensor([[0.5], [0.5]], dtype=torch.float32)
121
- ious = pairwise_iou_rotated(boxes1, boxes2)
122
- assert torch.allclose(ious, expected_ious)
123
-
124
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
125
- def test_iou_45_degrees_cuda(self):
126
- boxes1 = torch.tensor(
127
- [
128
- [1, 1, math.sqrt(2), math.sqrt(2), 45],
129
- [1, 1, 2 * math.sqrt(2), 2 * math.sqrt(2), -45],
130
- ],
131
- dtype=torch.float32,
132
- )
133
- boxes2 = torch.tensor([[1, 1, 2, 2, 0]], dtype=torch.float32)
134
- expected_ious = torch.tensor([[0.5], [0.5]], dtype=torch.float32)
135
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
136
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
137
-
138
- def test_iou_perpendicular_cpu(self):
139
- boxes1 = torch.tensor([[5, 5, 10.0, 6, 55]], dtype=torch.float32)
140
- boxes2 = torch.tensor([[5, 5, 10.0, 6, -35]], dtype=torch.float32)
141
- iou = (6.0 * 6.0) / (6.0 * 6.0 + 4.0 * 6.0 + 4.0 * 6.0)
142
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
143
- ious = pairwise_iou_rotated(boxes1, boxes2)
144
- self.assertTrue(torch.allclose(ious, expected_ious))
145
-
146
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
147
- def test_iou_perpendicular_cuda(self):
148
- boxes1 = torch.tensor([[5, 5, 10.0, 6, 55]], dtype=torch.float32)
149
- boxes2 = torch.tensor([[5, 5, 10.0, 6, -35]], dtype=torch.float32)
150
- iou = (6.0 * 6.0) / (6.0 * 6.0 + 4.0 * 6.0 + 4.0 * 6.0)
151
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
152
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
153
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
154
-
155
- def test_iou_large_close_boxes_cpu(self):
156
- boxes1 = torch.tensor(
157
- [[299.500000, 417.370422, 600.000000, 364.259186, 27.1828]], dtype=torch.float32
158
- )
159
- boxes2 = torch.tensor(
160
- [[299.500000, 417.370422, 600.000000, 364.259155, 27.1828]], dtype=torch.float32
161
- )
162
- iou = 364.259155 / 364.259186
163
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
164
- ious = pairwise_iou_rotated(boxes1, boxes2)
165
- self.assertTrue(torch.allclose(ious, expected_ious))
166
-
167
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
168
- def test_iou_large_close_boxes_cuda(self):
169
- boxes1 = torch.tensor(
170
- [[299.500000, 417.370422, 600.000000, 364.259186, 27.1828]], dtype=torch.float32
171
- )
172
- boxes2 = torch.tensor(
173
- [[299.500000, 417.370422, 600.000000, 364.259155, 27.1828]], dtype=torch.float32
174
- )
175
- iou = 364.259155 / 364.259186
176
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
177
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
178
- assert torch.allclose(ious_cuda.cpu(), expected_ious)
179
-
180
- def test_iou_precision_cpu(self):
181
- boxes1 = torch.tensor([[565, 565, 10, 10, 0]], dtype=torch.float32)
182
- boxes2 = torch.tensor([[565, 565, 10, 8.3, 0]], dtype=torch.float32)
183
- iou = 8.3 / 10.0
184
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
185
- ious = pairwise_iou_rotated(boxes1, boxes2)
186
- self.assertTrue(torch.allclose(ious, expected_ious))
187
-
188
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
189
- def test_iou_precision_cuda(self):
190
- boxes1 = torch.tensor([[565, 565, 10, 10, 0]], dtype=torch.float32)
191
- boxes2 = torch.tensor([[565, 565, 10, 8.3, 0]], dtype=torch.float32)
192
- iou = 8.3 / 10.0
193
- expected_ious = torch.tensor([[iou]], dtype=torch.float32)
194
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
195
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
196
-
197
- def test_iou_many_boxes_cpu(self):
198
- num_boxes1 = 100
199
- num_boxes2 = 200
200
- boxes1 = torch.stack(
201
- [
202
- torch.tensor([5 + 20 * i, 5 + 20 * i, 10, 10, 0], dtype=torch.float32)
203
- for i in range(num_boxes1)
204
- ]
205
- )
206
- boxes2 = torch.stack(
207
- [
208
- torch.tensor(
209
- [5 + 20 * i, 5 + 20 * i, 10, 1 + 9 * i / num_boxes2, 0], dtype=torch.float32
210
- )
211
- for i in range(num_boxes2)
212
- ]
213
- )
214
- expected_ious = torch.zeros(num_boxes1, num_boxes2, dtype=torch.float32)
215
- for i in range(min(num_boxes1, num_boxes2)):
216
- expected_ious[i][i] = (1 + 9 * i / num_boxes2) / 10.0
217
- ious = pairwise_iou_rotated(boxes1, boxes2)
218
- self.assertTrue(torch.allclose(ious, expected_ious))
219
-
220
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
221
- def test_iou_many_boxes_cuda(self):
222
- num_boxes1 = 100
223
- num_boxes2 = 200
224
- boxes1 = torch.stack(
225
- [
226
- torch.tensor([5 + 20 * i, 5 + 20 * i, 10, 10, 0], dtype=torch.float32)
227
- for i in range(num_boxes1)
228
- ]
229
- )
230
- boxes2 = torch.stack(
231
- [
232
- torch.tensor(
233
- [5 + 20 * i, 5 + 20 * i, 10, 1 + 9 * i / num_boxes2, 0], dtype=torch.float32
234
- )
235
- for i in range(num_boxes2)
236
- ]
237
- )
238
- expected_ious = torch.zeros(num_boxes1, num_boxes2, dtype=torch.float32)
239
- for i in range(min(num_boxes1, num_boxes2)):
240
- expected_ious[i][i] = (1 + 9 * i / num_boxes2) / 10.0
241
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
242
- self.assertTrue(torch.allclose(ious_cuda.cpu(), expected_ious))
243
-
244
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
245
- def test_iou_too_many_boxes_cuda(self):
246
- s1, s2 = 5, 1289035
247
- boxes1 = torch.zeros(s1, 5)
248
- boxes2 = torch.zeros(s2, 5)
249
- ious_cuda = pairwise_iou_rotated(boxes1.cuda(), boxes2.cuda())
250
- self.assertTupleEqual(tuple(ious_cuda.shape), (s1, s2))
251
-
252
-
253
- class TestRotatedBoxesStructure(unittest.TestCase):
254
- def test_clip_area_0_degree(self):
255
- for _ in range(50):
256
- num_boxes = 100
257
- boxes_5d = torch.zeros(num_boxes, 5)
258
- boxes_5d[:, 0] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
259
- boxes_5d[:, 1] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
260
- boxes_5d[:, 2] = torch.FloatTensor(num_boxes).uniform_(0, 500)
261
- boxes_5d[:, 3] = torch.FloatTensor(num_boxes).uniform_(0, 500)
262
- # Convert from (x_ctr, y_ctr, w, h, 0) to (x1, y1, x2, y2)
263
- boxes_4d = torch.zeros(num_boxes, 4)
264
- boxes_4d[:, 0] = boxes_5d[:, 0] - boxes_5d[:, 2] / 2.0
265
- boxes_4d[:, 1] = boxes_5d[:, 1] - boxes_5d[:, 3] / 2.0
266
- boxes_4d[:, 2] = boxes_5d[:, 0] + boxes_5d[:, 2] / 2.0
267
- boxes_4d[:, 3] = boxes_5d[:, 1] + boxes_5d[:, 3] / 2.0
268
-
269
- image_size = (500, 600)
270
- test_boxes_4d = Boxes(boxes_4d)
271
- test_boxes_5d = RotatedBoxes(boxes_5d)
272
- # Before clip
273
- areas_4d = test_boxes_4d.area()
274
- areas_5d = test_boxes_5d.area()
275
- self.assertTrue(torch.allclose(areas_4d, areas_5d, atol=1e-1, rtol=1e-5))
276
- # After clip
277
- test_boxes_4d.clip(image_size)
278
- test_boxes_5d.clip(image_size)
279
- areas_4d = test_boxes_4d.area()
280
- areas_5d = test_boxes_5d.area()
281
- self.assertTrue(torch.allclose(areas_4d, areas_5d, atol=1e-1, rtol=1e-5))
282
-
283
- def test_clip_area_arbitrary_angle(self):
284
- num_boxes = 100
285
- boxes_5d = torch.zeros(num_boxes, 5)
286
- boxes_5d[:, 0] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
287
- boxes_5d[:, 1] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
288
- boxes_5d[:, 2] = torch.FloatTensor(num_boxes).uniform_(0, 500)
289
- boxes_5d[:, 3] = torch.FloatTensor(num_boxes).uniform_(0, 500)
290
- boxes_5d[:, 4] = torch.FloatTensor(num_boxes).uniform_(-1800, 1800)
291
- clip_angle_threshold = random.uniform(0, 180)
292
-
293
- image_size = (500, 600)
294
- test_boxes_5d = RotatedBoxes(boxes_5d)
295
- # Before clip
296
- areas_before = test_boxes_5d.area()
297
- # After clip
298
- test_boxes_5d.clip(image_size, clip_angle_threshold)
299
- areas_diff = test_boxes_5d.area() - areas_before
300
-
301
- # the areas should only decrease after clipping
302
- self.assertTrue(torch.all(areas_diff <= 0))
303
- # whenever the box is clipped (thus the area shrinks),
304
- # the angle for the box must be within the clip_angle_threshold
305
- # Note that the clip function will normalize the angle range
306
- # to be within (-180, 180]
307
- self.assertTrue(
308
- torch.all(torch.abs(boxes_5d[:, 4][torch.where(areas_diff < 0)]) < clip_angle_threshold)
309
- )
310
-
311
- def test_normalize_angles(self):
312
- # torch.manual_seed(0)
313
- for _ in range(50):
314
- num_boxes = 100
315
- boxes_5d = torch.zeros(num_boxes, 5)
316
- boxes_5d[:, 0] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
317
- boxes_5d[:, 1] = torch.FloatTensor(num_boxes).uniform_(-100, 500)
318
- boxes_5d[:, 2] = torch.FloatTensor(num_boxes).uniform_(0, 500)
319
- boxes_5d[:, 3] = torch.FloatTensor(num_boxes).uniform_(0, 500)
320
- boxes_5d[:, 4] = torch.FloatTensor(num_boxes).uniform_(-1800, 1800)
321
- rotated_boxes = RotatedBoxes(boxes_5d)
322
- normalized_boxes = rotated_boxes.clone()
323
- normalized_boxes.normalize_angles()
324
- self.assertTrue(torch.all(normalized_boxes.tensor[:, 4] >= -180))
325
- self.assertTrue(torch.all(normalized_boxes.tensor[:, 4] < 180))
326
- # x, y, w, h should not change
327
- self.assertTrue(torch.allclose(boxes_5d[:, :4], normalized_boxes.tensor[:, :4]))
328
- # the cos/sin values of the angles should stay the same
329
-
330
- self.assertTrue(
331
- torch.allclose(
332
- torch.cos(boxes_5d[:, 4] * math.pi / 180),
333
- torch.cos(normalized_boxes.tensor[:, 4] * math.pi / 180),
334
- atol=1e-5,
335
- )
336
- )
337
-
338
- self.assertTrue(
339
- torch.allclose(
340
- torch.sin(boxes_5d[:, 4] * math.pi / 180),
341
- torch.sin(normalized_boxes.tensor[:, 4] * math.pi / 180),
342
- atol=1e-5,
343
- )
344
- )
345
-
346
- def test_pairwise_iou_0_degree_cpu(self):
347
- device = torch.device("cpu")
348
- boxes1 = torch.tensor(
349
- [[0.5, 0.5, 1.0, 1.0, 0.0], [0.5, 0.5, 1.0, 1.0, 0.0]],
350
- dtype=torch.float32,
351
- device=device,
352
- )
353
- boxes2 = torch.tensor(
354
- [
355
- [0.5, 0.5, 1.0, 1.0, 0.0],
356
- [0.25, 0.5, 0.5, 1.0, 0.0],
357
- [0.5, 0.25, 1.0, 0.5, 0.0],
358
- [0.25, 0.25, 0.5, 0.5, 0.0],
359
- [0.75, 0.75, 0.5, 0.5, 0.0],
360
- [1.0, 1.0, 1.0, 1.0, 0.0],
361
- ],
362
- dtype=torch.float32,
363
- device=device,
364
- )
365
- expected_ious = torch.tensor(
366
- [
367
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
368
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
369
- ],
370
- dtype=torch.float32,
371
- device=device,
372
- )
373
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
374
- self.assertTrue(torch.allclose(ious, expected_ious))
375
-
376
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
377
- def test_pairwise_iou_0_degree_cuda(self):
378
- device = torch.device("cuda")
379
- boxes1 = torch.tensor(
380
- [[0.5, 0.5, 1.0, 1.0, 0.0], [0.5, 0.5, 1.0, 1.0, 0.0]],
381
- dtype=torch.float32,
382
- device=device,
383
- )
384
- boxes2 = torch.tensor(
385
- [
386
- [0.5, 0.5, 1.0, 1.0, 0.0],
387
- [0.25, 0.5, 0.5, 1.0, 0.0],
388
- [0.5, 0.25, 1.0, 0.5, 0.0],
389
- [0.25, 0.25, 0.5, 0.5, 0.0],
390
- [0.75, 0.75, 0.5, 0.5, 0.0],
391
- [1.0, 1.0, 1.0, 1.0, 0.0],
392
- ],
393
- dtype=torch.float32,
394
- device=device,
395
- )
396
- expected_ious = torch.tensor(
397
- [
398
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
399
- [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
400
- ],
401
- dtype=torch.float32,
402
- device=device,
403
- )
404
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
405
- self.assertTrue(torch.allclose(ious, expected_ious))
406
-
407
- def test_pairwise_iou_45_degrees_cpu(self):
408
- device = torch.device("cpu")
409
- boxes1 = torch.tensor(
410
- [
411
- [1, 1, math.sqrt(2), math.sqrt(2), 45],
412
- [1, 1, 2 * math.sqrt(2), 2 * math.sqrt(2), -45],
413
- ],
414
- dtype=torch.float32,
415
- device=device,
416
- )
417
- boxes2 = torch.tensor([[1, 1, 2, 2, 0]], dtype=torch.float32, device=device)
418
- expected_ious = torch.tensor([[0.5], [0.5]], dtype=torch.float32, device=device)
419
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
420
- self.assertTrue(torch.allclose(ious, expected_ious))
421
-
422
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
423
- def test_pairwise_iou_45_degrees_cuda(self):
424
- device = torch.device("cuda")
425
- boxes1 = torch.tensor(
426
- [
427
- [1, 1, math.sqrt(2), math.sqrt(2), 45],
428
- [1, 1, 2 * math.sqrt(2), 2 * math.sqrt(2), -45],
429
- ],
430
- dtype=torch.float32,
431
- device=device,
432
- )
433
- boxes2 = torch.tensor([[1, 1, 2, 2, 0]], dtype=torch.float32, device=device)
434
- expected_ious = torch.tensor([[0.5], [0.5]], dtype=torch.float32, device=device)
435
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
436
- self.assertTrue(torch.allclose(ious, expected_ious))
437
-
438
- def test_pairwise_iou_orthogonal_cpu(self):
439
- device = torch.device("cpu")
440
- boxes1 = torch.tensor([[5, 5, 10, 6, 55]], dtype=torch.float32, device=device)
441
- boxes2 = torch.tensor([[5, 5, 10, 6, -35]], dtype=torch.float32, device=device)
442
- iou = (6.0 * 6.0) / (6.0 * 6.0 + 4.0 * 6.0 + 4.0 * 6.0)
443
- expected_ious = torch.tensor([[iou]], dtype=torch.float32, device=device)
444
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
445
- self.assertTrue(torch.allclose(ious, expected_ious))
446
-
447
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
448
- def test_pairwise_iou_orthogonal_cuda(self):
449
- device = torch.device("cuda")
450
- boxes1 = torch.tensor([[5, 5, 10, 6, 55]], dtype=torch.float32, device=device)
451
- boxes2 = torch.tensor([[5, 5, 10, 6, -35]], dtype=torch.float32, device=device)
452
- iou = (6.0 * 6.0) / (6.0 * 6.0 + 4.0 * 6.0 + 4.0 * 6.0)
453
- expected_ious = torch.tensor([[iou]], dtype=torch.float32, device=device)
454
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
455
- self.assertTrue(torch.allclose(ious, expected_ious))
456
-
457
- def test_pairwise_iou_large_close_boxes_cpu(self):
458
- device = torch.device("cpu")
459
- boxes1 = torch.tensor(
460
- [[299.500000, 417.370422, 600.000000, 364.259186, 27.1828]],
461
- dtype=torch.float32,
462
- device=device,
463
- )
464
- boxes2 = torch.tensor(
465
- [[299.500000, 417.370422, 600.000000, 364.259155, 27.1828]],
466
- dtype=torch.float32,
467
- device=device,
468
- )
469
- iou = 364.259155 / 364.259186
470
- expected_ious = torch.tensor([[iou]], dtype=torch.float32, device=device)
471
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
472
- self.assertTrue(torch.allclose(ious, expected_ious))
473
-
474
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
475
- def test_pairwise_iou_large_close_boxes_cuda(self):
476
- device = torch.device("cuda")
477
- boxes1 = torch.tensor(
478
- [[299.500000, 417.370422, 600.000000, 364.259186, 27.1828]],
479
- dtype=torch.float32,
480
- device=device,
481
- )
482
- boxes2 = torch.tensor(
483
- [[299.500000, 417.370422, 600.000000, 364.259155, 27.1828]],
484
- dtype=torch.float32,
485
- device=device,
486
- )
487
- iou = 364.259155 / 364.259186
488
- expected_ious = torch.tensor([[iou]], dtype=torch.float32, device=device)
489
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
490
- self.assertTrue(torch.allclose(ious, expected_ious))
491
-
492
- def test_pairwise_iou_many_boxes_cpu(self):
493
- device = torch.device("cpu")
494
- num_boxes1 = 100
495
- num_boxes2 = 200
496
- boxes1 = torch.stack(
497
- [
498
- torch.tensor(
499
- [5 + 20 * i, 5 + 20 * i, 10, 10, 0], dtype=torch.float32, device=device
500
- )
501
- for i in range(num_boxes1)
502
- ]
503
- )
504
- boxes2 = torch.stack(
505
- [
506
- torch.tensor(
507
- [5 + 20 * i, 5 + 20 * i, 10, 1 + 9 * i / num_boxes2, 0],
508
- dtype=torch.float32,
509
- device=device,
510
- )
511
- for i in range(num_boxes2)
512
- ]
513
- )
514
- expected_ious = torch.zeros(num_boxes1, num_boxes2, dtype=torch.float32, device=device)
515
- for i in range(min(num_boxes1, num_boxes2)):
516
- expected_ious[i][i] = (1 + 9 * i / num_boxes2) / 10.0
517
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
518
- self.assertTrue(torch.allclose(ious, expected_ious))
519
-
520
- @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
521
- def test_pairwise_iou_many_boxes_cuda(self):
522
- device = torch.device("cuda")
523
- num_boxes1 = 100
524
- num_boxes2 = 200
525
- boxes1 = torch.stack(
526
- [
527
- torch.tensor(
528
- [5 + 20 * i, 5 + 20 * i, 10, 10, 0], dtype=torch.float32, device=device
529
- )
530
- for i in range(num_boxes1)
531
- ]
532
- )
533
- boxes2 = torch.stack(
534
- [
535
- torch.tensor(
536
- [5 + 20 * i, 5 + 20 * i, 10, 1 + 9 * i / num_boxes2, 0],
537
- dtype=torch.float32,
538
- device=device,
539
- )
540
- for i in range(num_boxes2)
541
- ]
542
- )
543
- expected_ious = torch.zeros(num_boxes1, num_boxes2, dtype=torch.float32, device=device)
544
- for i in range(min(num_boxes1, num_boxes2)):
545
- expected_ious[i][i] = (1 + 9 * i / num_boxes2) / 10.0
546
- ious = pairwise_iou(RotatedBoxes(boxes1), RotatedBoxes(boxes2))
547
- self.assertTrue(torch.allclose(ious, expected_ious))
548
-
549
-
550
- def benchmark_rotated_iou():
551
- num_boxes1 = 200
552
- num_boxes2 = 500
553
- boxes1 = torch.stack(
554
- [
555
- torch.tensor([5 + 20 * i, 5 + 20 * i, 10, 10, 0], dtype=torch.float32)
556
- for i in range(num_boxes1)
557
- ]
558
- )
559
- boxes2 = torch.stack(
560
- [
561
- torch.tensor(
562
- [5 + 20 * i, 5 + 20 * i, 10, 1 + 9 * i / num_boxes2, 0], dtype=torch.float32
563
- )
564
- for i in range(num_boxes2)
565
- ]
566
- )
567
-
568
- def func(dev, n=1):
569
- b1 = boxes1.to(device=dev)
570
- b2 = boxes2.to(device=dev)
571
-
572
- def bench():
573
- for _ in range(n):
574
- pairwise_iou_rotated(b1, b2)
575
- if dev.type == "cuda":
576
- torch.cuda.synchronize()
577
-
578
- return bench
579
-
580
- # only run it once per timed loop, since it's slow
581
- args = [{"dev": torch.device("cpu"), "n": 1}]
582
- if torch.cuda.is_available():
583
- args.append({"dev": torch.device("cuda"), "n": 10})
584
-
585
- benchmark(func, "rotated_iou", args, warmup_iters=3)
586
-
587
-
588
- if __name__ == "__main__":
589
- unittest.main()
590
- benchmark_rotated_iou()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/CVPR/LIVE/thrust/internal/scripts/refresh_from_github2.sh DELETED
@@ -1,96 +0,0 @@
1
- branch="master"
2
-
3
- while getopts "hb:c:" opt; do
4
- case $opt in
5
- h)
6
- echo "Usage: $0 [-h] [-b <github_branch_name>] -c <P4_changelist>"
7
- exit 1
8
- ;;
9
-
10
- b)
11
- branch=$OPTARG
12
- ;;
13
-
14
- c)
15
- changelist=$OPTARG
16
- ;;
17
-
18
- /?)
19
- echo "Invalid option: -$OPTARG" >&2;
20
- exit 1
21
- ;;
22
-
23
- :)
24
- echo "Option -$OPTARG requires an argument";
25
- exit 1
26
- ;;
27
- esac
28
- done
29
-
30
- if [ "$changelist" == "" ]; then
31
- echo "Missing required option -c to specify P4 changelist to put changed files into"
32
- exit 1
33
- fi
34
-
35
- # Cause script to exit on any command that results in an error
36
- set -e
37
-
38
- echo "Downloading thrust code from the $branch branch into /tmp/thrust-${branch}"
39
- rm -rf /tmp/thrust-${branch}
40
- git clone -q git://github.com/thrust/thrust.git -b ${branch} /tmp/thrust-${branch}
41
-
42
- cd `dirname $0`/../..
43
- echo "Changed current directory to `pwd`"
44
-
45
- vulcan_files=`echo *.vlcc *.vlct`
46
- logdir=`mktemp -d /tmp/tmp.XXXXXXXX`
47
- echo "Logging p4 command outputs to temporary directory $logdir"
48
- for i in *; do
49
- if [[ "$i" != "internal" && "$i" != "Makefile" ]]; then
50
- ii="$i";
51
- if [ -d $i ]; then ii="$i/..."; fi
52
- echo "Reverting, force syncing, and then removing $ii"
53
- p4 revert $ii >> $logdir/$i.revert.log 2>&1
54
- p4 sync -f $ii >> $logdir/$i.sync.log 2>&1
55
- rm -rf $i
56
- fi
57
- done
58
-
59
- echo "Copying downloaded thrust code to p4 client"
60
- cp -R /tmp/thrust-${branch}/* .
61
- find . -name ".gitignore" | xargs -n 1 rm
62
-
63
- echo "Checking if version has been bumped"
64
- new_version=`grep "#define THRUST_VERSION" thrust/version.h | sed -e "s/#define THRUST_VERSION //"`
65
- old_version=`p4 print thrust/version.h | grep "#define THRUST_VERSION" | sed -e "s/#define THRUST_VERSION //"`
66
- if [ "$new_version" != "$old_version" ]; then
67
- p4 edit internal/test/version.gold
68
- new_version_print="$(( $new_version / 100000 )).$(( ($new_version / 100) % 1000 )).$(( $new_version % 100 ))"
69
- sed -e "s/v[0-9\.][0-9\.]*/v${new_version_print}/" internal/test/version.gold > internal/test/version.gold.tmp
70
- mv internal/test/version.gold.tmp internal/test/version.gold
71
- echo "Updated version.gold to version $new_version_print"
72
- else
73
- echo "Version has not changed"
74
- fi
75
-
76
- echo "Reconciling changed code into changelist $changelist"
77
- p4 reconcile -c $changelist ... >> $logdir/reconcile.log 2>&1
78
- p4 revert -c $changelist Makefile $vulcan_files internal/... >> $logdir/internal_files_revert.log 2>&1
79
-
80
- echo "Looking for examples that were added"
81
- for e in `find examples -name "*.cu"`; do
82
- if [ ! -e internal/build/`basename $e .cu`.mk ]; then
83
- echo "ADDED: `basename $e .cu`";
84
- fi
85
- done
86
-
87
- echo "Looking for examples that were deleted or moved"
88
- for e in `find internal/build -name "*.mk"`; do
89
- ee=`basename $e .mk`
90
- case "$ee" in
91
- generic_example | unittester* | warningstester) continue;;
92
- esac
93
- if [ "`find examples -name $ee.cu`" == "" ]; then
94
- echo "DELETED: $ee";
95
- fi;
96
- done
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/CVPR/WALT/mmdet/core/bbox/assigners/center_region_assigner.py DELETED
@@ -1,335 +0,0 @@
1
- import torch
2
-
3
- from ..builder import BBOX_ASSIGNERS
4
- from ..iou_calculators import build_iou_calculator
5
- from .assign_result import AssignResult
6
- from .base_assigner import BaseAssigner
7
-
8
-
9
- def scale_boxes(bboxes, scale):
10
- """Expand an array of boxes by a given scale.
11
-
12
- Args:
13
- bboxes (Tensor): Shape (m, 4)
14
- scale (float): The scale factor of bboxes
15
-
16
- Returns:
17
- (Tensor): Shape (m, 4). Scaled bboxes
18
- """
19
- assert bboxes.size(1) == 4
20
- w_half = (bboxes[:, 2] - bboxes[:, 0]) * .5
21
- h_half = (bboxes[:, 3] - bboxes[:, 1]) * .5
22
- x_c = (bboxes[:, 2] + bboxes[:, 0]) * .5
23
- y_c = (bboxes[:, 3] + bboxes[:, 1]) * .5
24
-
25
- w_half *= scale
26
- h_half *= scale
27
-
28
- boxes_scaled = torch.zeros_like(bboxes)
29
- boxes_scaled[:, 0] = x_c - w_half
30
- boxes_scaled[:, 2] = x_c + w_half
31
- boxes_scaled[:, 1] = y_c - h_half
32
- boxes_scaled[:, 3] = y_c + h_half
33
- return boxes_scaled
34
-
35
-
36
- def is_located_in(points, bboxes):
37
- """Are points located in bboxes.
38
-
39
- Args:
40
- points (Tensor): Points, shape: (m, 2).
41
- bboxes (Tensor): Bounding boxes, shape: (n, 4).
42
-
43
- Return:
44
- Tensor: Flags indicating if points are located in bboxes, shape: (m, n).
45
- """
46
- assert points.size(1) == 2
47
- assert bboxes.size(1) == 4
48
- return (points[:, 0].unsqueeze(1) > bboxes[:, 0].unsqueeze(0)) & \
49
- (points[:, 0].unsqueeze(1) < bboxes[:, 2].unsqueeze(0)) & \
50
- (points[:, 1].unsqueeze(1) > bboxes[:, 1].unsqueeze(0)) & \
51
- (points[:, 1].unsqueeze(1) < bboxes[:, 3].unsqueeze(0))
52
-
53
-
54
- def bboxes_area(bboxes):
55
- """Compute the area of an array of bboxes.
56
-
57
- Args:
58
- bboxes (Tensor): The coordinates ox bboxes. Shape: (m, 4)
59
-
60
- Returns:
61
- Tensor: Area of the bboxes. Shape: (m, )
62
- """
63
- assert bboxes.size(1) == 4
64
- w = (bboxes[:, 2] - bboxes[:, 0])
65
- h = (bboxes[:, 3] - bboxes[:, 1])
66
- areas = w * h
67
- return areas
68
-
69
-
70
- @BBOX_ASSIGNERS.register_module()
71
- class CenterRegionAssigner(BaseAssigner):
72
- """Assign pixels at the center region of a bbox as positive.
73
-
74
- Each proposals will be assigned with `-1`, `0`, or a positive integer
75
- indicating the ground truth index.
76
- - -1: negative samples
77
- - semi-positive numbers: positive sample, index (0-based) of assigned gt
78
-
79
- Args:
80
- pos_scale (float): Threshold within which pixels are
81
- labelled as positive.
82
- neg_scale (float): Threshold above which pixels are
83
- labelled as positive.
84
- min_pos_iof (float): Minimum iof of a pixel with a gt to be
85
- labelled as positive. Default: 1e-2
86
- ignore_gt_scale (float): Threshold within which the pixels
87
- are ignored when the gt is labelled as shadowed. Default: 0.5
88
- foreground_dominate (bool): If True, the bbox will be assigned as
89
- positive when a gt's kernel region overlaps with another's shadowed
90
- (ignored) region, otherwise it is set as ignored. Default to False.
91
- """
92
-
93
- def __init__(self,
94
- pos_scale,
95
- neg_scale,
96
- min_pos_iof=1e-2,
97
- ignore_gt_scale=0.5,
98
- foreground_dominate=False,
99
- iou_calculator=dict(type='BboxOverlaps2D')):
100
- self.pos_scale = pos_scale
101
- self.neg_scale = neg_scale
102
- self.min_pos_iof = min_pos_iof
103
- self.ignore_gt_scale = ignore_gt_scale
104
- self.foreground_dominate = foreground_dominate
105
- self.iou_calculator = build_iou_calculator(iou_calculator)
106
-
107
- def get_gt_priorities(self, gt_bboxes):
108
- """Get gt priorities according to their areas.
109
-
110
- Smaller gt has higher priority.
111
-
112
- Args:
113
- gt_bboxes (Tensor): Ground truth boxes, shape (k, 4).
114
-
115
- Returns:
116
- Tensor: The priority of gts so that gts with larger priority is \
117
- more likely to be assigned. Shape (k, )
118
- """
119
- gt_areas = bboxes_area(gt_bboxes)
120
- # Rank all gt bbox areas. Smaller objects has larger priority
121
- _, sort_idx = gt_areas.sort(descending=True)
122
- sort_idx = sort_idx.argsort()
123
- return sort_idx
124
-
125
- def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None):
126
- """Assign gt to bboxes.
127
-
128
- This method assigns gts to every bbox (proposal/anchor), each bbox \
129
- will be assigned with -1, or a semi-positive number. -1 means \
130
- negative sample, semi-positive number is the index (0-based) of \
131
- assigned gt.
132
-
133
- Args:
134
- bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4).
135
- gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4).
136
- gt_bboxes_ignore (tensor, optional): Ground truth bboxes that are
137
- labelled as `ignored`, e.g., crowd boxes in COCO.
138
- gt_labels (tensor, optional): Label of gt_bboxes, shape (num_gts,).
139
-
140
- Returns:
141
- :obj:`AssignResult`: The assigned result. Note that \
142
- shadowed_labels of shape (N, 2) is also added as an \
143
- `assign_result` attribute. `shadowed_labels` is a tensor \
144
- composed of N pairs of anchor_ind, class_label], where N \
145
- is the number of anchors that lie in the outer region of a \
146
- gt, anchor_ind is the shadowed anchor index and class_label \
147
- is the shadowed class label.
148
-
149
- Example:
150
- >>> self = CenterRegionAssigner(0.2, 0.2)
151
- >>> bboxes = torch.Tensor([[0, 0, 10, 10], [10, 10, 20, 20]])
152
- >>> gt_bboxes = torch.Tensor([[0, 0, 10, 10]])
153
- >>> assign_result = self.assign(bboxes, gt_bboxes)
154
- >>> expected_gt_inds = torch.LongTensor([1, 0])
155
- >>> assert torch.all(assign_result.gt_inds == expected_gt_inds)
156
- """
157
- # There are in total 5 steps in the pixel assignment
158
- # 1. Find core (the center region, say inner 0.2)
159
- # and shadow (the relatively ourter part, say inner 0.2-0.5)
160
- # regions of every gt.
161
- # 2. Find all prior bboxes that lie in gt_core and gt_shadow regions
162
- # 3. Assign prior bboxes in gt_core with a one-hot id of the gt in
163
- # the image.
164
- # 3.1. For overlapping objects, the prior bboxes in gt_core is
165
- # assigned with the object with smallest area
166
- # 4. Assign prior bboxes with class label according to its gt id.
167
- # 4.1. Assign -1 to prior bboxes lying in shadowed gts
168
- # 4.2. Assign positive prior boxes with the corresponding label
169
- # 5. Find pixels lying in the shadow of an object and assign them with
170
- # background label, but set the loss weight of its corresponding
171
- # gt to zero.
172
- assert bboxes.size(1) == 4, 'bboxes must have size of 4'
173
- # 1. Find core positive and shadow region of every gt
174
- gt_core = scale_boxes(gt_bboxes, self.pos_scale)
175
- gt_shadow = scale_boxes(gt_bboxes, self.neg_scale)
176
-
177
- # 2. Find prior bboxes that lie in gt_core and gt_shadow regions
178
- bbox_centers = (bboxes[:, 2:4] + bboxes[:, 0:2]) / 2
179
- # The center points lie within the gt boxes
180
- is_bbox_in_gt = is_located_in(bbox_centers, gt_bboxes)
181
- # Only calculate bbox and gt_core IoF. This enables small prior bboxes
182
- # to match large gts
183
- bbox_and_gt_core_overlaps = self.iou_calculator(
184
- bboxes, gt_core, mode='iof')
185
- # The center point of effective priors should be within the gt box
186
- is_bbox_in_gt_core = is_bbox_in_gt & (
187
- bbox_and_gt_core_overlaps > self.min_pos_iof) # shape (n, k)
188
-
189
- is_bbox_in_gt_shadow = (
190
- self.iou_calculator(bboxes, gt_shadow, mode='iof') >
191
- self.min_pos_iof)
192
- # Rule out center effective positive pixels
193
- is_bbox_in_gt_shadow &= (~is_bbox_in_gt_core)
194
-
195
- num_gts, num_bboxes = gt_bboxes.size(0), bboxes.size(0)
196
- if num_gts == 0 or num_bboxes == 0:
197
- # If no gts exist, assign all pixels to negative
198
- assigned_gt_ids = \
199
- is_bbox_in_gt_core.new_zeros((num_bboxes,),
200
- dtype=torch.long)
201
- pixels_in_gt_shadow = assigned_gt_ids.new_empty((0, 2))
202
- else:
203
- # Step 3: assign a one-hot gt id to each pixel, and smaller objects
204
- # have high priority to assign the pixel.
205
- sort_idx = self.get_gt_priorities(gt_bboxes)
206
- assigned_gt_ids, pixels_in_gt_shadow = \
207
- self.assign_one_hot_gt_indices(is_bbox_in_gt_core,
208
- is_bbox_in_gt_shadow,
209
- gt_priority=sort_idx)
210
-
211
- if gt_bboxes_ignore is not None and gt_bboxes_ignore.numel() > 0:
212
- # No ground truth or boxes, return empty assignment
213
- gt_bboxes_ignore = scale_boxes(
214
- gt_bboxes_ignore, scale=self.ignore_gt_scale)
215
- is_bbox_in_ignored_gts = is_located_in(bbox_centers,
216
- gt_bboxes_ignore)
217
- is_bbox_in_ignored_gts = is_bbox_in_ignored_gts.any(dim=1)
218
- assigned_gt_ids[is_bbox_in_ignored_gts] = -1
219
-
220
- # 4. Assign prior bboxes with class label according to its gt id.
221
- assigned_labels = None
222
- shadowed_pixel_labels = None
223
- if gt_labels is not None:
224
- # Default assigned label is the background (-1)
225
- assigned_labels = assigned_gt_ids.new_full((num_bboxes, ), -1)
226
- pos_inds = torch.nonzero(
227
- assigned_gt_ids > 0, as_tuple=False).squeeze()
228
- if pos_inds.numel() > 0:
229
- assigned_labels[pos_inds] = gt_labels[assigned_gt_ids[pos_inds]
230
- - 1]
231
- # 5. Find pixels lying in the shadow of an object
232
- shadowed_pixel_labels = pixels_in_gt_shadow.clone()
233
- if pixels_in_gt_shadow.numel() > 0:
234
- pixel_idx, gt_idx =\
235
- pixels_in_gt_shadow[:, 0], pixels_in_gt_shadow[:, 1]
236
- assert (assigned_gt_ids[pixel_idx] != gt_idx).all(), \
237
- 'Some pixels are dually assigned to ignore and gt!'
238
- shadowed_pixel_labels[:, 1] = gt_labels[gt_idx - 1]
239
- override = (
240
- assigned_labels[pixel_idx] == shadowed_pixel_labels[:, 1])
241
- if self.foreground_dominate:
242
- # When a pixel is both positive and shadowed, set it as pos
243
- shadowed_pixel_labels = shadowed_pixel_labels[~override]
244
- else:
245
- # When a pixel is both pos and shadowed, set it as shadowed
246
- assigned_labels[pixel_idx[override]] = -1
247
- assigned_gt_ids[pixel_idx[override]] = 0
248
-
249
- assign_result = AssignResult(
250
- num_gts, assigned_gt_ids, None, labels=assigned_labels)
251
- # Add shadowed_labels as assign_result property. Shape: (num_shadow, 2)
252
- assign_result.set_extra_property('shadowed_labels',
253
- shadowed_pixel_labels)
254
- return assign_result
255
-
256
- def assign_one_hot_gt_indices(self,
257
- is_bbox_in_gt_core,
258
- is_bbox_in_gt_shadow,
259
- gt_priority=None):
260
- """Assign only one gt index to each prior box.
261
-
262
- Gts with large gt_priority are more likely to be assigned.
263
-
264
- Args:
265
- is_bbox_in_gt_core (Tensor): Bool tensor indicating the bbox center
266
- is in the core area of a gt (e.g. 0-0.2).
267
- Shape: (num_prior, num_gt).
268
- is_bbox_in_gt_shadow (Tensor): Bool tensor indicating the bbox
269
- center is in the shadowed area of a gt (e.g. 0.2-0.5).
270
- Shape: (num_prior, num_gt).
271
- gt_priority (Tensor): Priorities of gts. The gt with a higher
272
- priority is more likely to be assigned to the bbox when the bbox
273
- match with multiple gts. Shape: (num_gt, ).
274
-
275
- Returns:
276
- tuple: Returns (assigned_gt_inds, shadowed_gt_inds).
277
-
278
- - assigned_gt_inds: The assigned gt index of each prior bbox \
279
- (i.e. index from 1 to num_gts). Shape: (num_prior, ).
280
- - shadowed_gt_inds: shadowed gt indices. It is a tensor of \
281
- shape (num_ignore, 2) with first column being the \
282
- shadowed prior bbox indices and the second column the \
283
- shadowed gt indices (1-based).
284
- """
285
- num_bboxes, num_gts = is_bbox_in_gt_core.shape
286
-
287
- if gt_priority is None:
288
- gt_priority = torch.arange(
289
- num_gts, device=is_bbox_in_gt_core.device)
290
- assert gt_priority.size(0) == num_gts
291
- # The bigger gt_priority, the more preferable to be assigned
292
- # The assigned inds are by default 0 (background)
293
- assigned_gt_inds = is_bbox_in_gt_core.new_zeros((num_bboxes, ),
294
- dtype=torch.long)
295
- # Shadowed bboxes are assigned to be background. But the corresponding
296
- # label is ignored during loss calculation, which is done through
297
- # shadowed_gt_inds
298
- shadowed_gt_inds = torch.nonzero(is_bbox_in_gt_shadow, as_tuple=False)
299
- if is_bbox_in_gt_core.sum() == 0: # No gt match
300
- shadowed_gt_inds[:, 1] += 1 # 1-based. For consistency issue
301
- return assigned_gt_inds, shadowed_gt_inds
302
-
303
- # The priority of each prior box and gt pair. If one prior box is
304
- # matched bo multiple gts. Only the pair with the highest priority
305
- # is saved
306
- pair_priority = is_bbox_in_gt_core.new_full((num_bboxes, num_gts),
307
- -1,
308
- dtype=torch.long)
309
-
310
- # Each bbox could match with multiple gts.
311
- # The following codes deal with this situation
312
- # Matched bboxes (to any gt). Shape: (num_pos_anchor, )
313
- inds_of_match = torch.any(is_bbox_in_gt_core, dim=1)
314
- # The matched gt index of each positive bbox. Length >= num_pos_anchor
315
- # , since one bbox could match multiple gts
316
- matched_bbox_gt_inds = torch.nonzero(
317
- is_bbox_in_gt_core, as_tuple=False)[:, 1]
318
- # Assign priority to each bbox-gt pair.
319
- pair_priority[is_bbox_in_gt_core] = gt_priority[matched_bbox_gt_inds]
320
- _, argmax_priority = pair_priority[inds_of_match].max(dim=1)
321
- assigned_gt_inds[inds_of_match] = argmax_priority + 1 # 1-based
322
- # Zero-out the assigned anchor box to filter the shadowed gt indices
323
- is_bbox_in_gt_core[inds_of_match, argmax_priority] = 0
324
- # Concat the shadowed indices due to overlapping with that out side of
325
- # effective scale. shape: (total_num_ignore, 2)
326
- shadowed_gt_inds = torch.cat(
327
- (shadowed_gt_inds, torch.nonzero(
328
- is_bbox_in_gt_core, as_tuple=False)),
329
- dim=0)
330
- # `is_bbox_in_gt_core` should be changed back to keep arguments intact.
331
- is_bbox_in_gt_core[inds_of_match, argmax_priority] = 1
332
- # 1-based shadowed gt indices, to be consistent with `assigned_gt_inds`
333
- if shadowed_gt_inds.numel() > 0:
334
- shadowed_gt_inds[:, 1] += 1
335
- return assigned_gt_inds, shadowed_gt_inds
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/ClearLove443/Robby-chatbot/pages/2_📊 Robby-Sheet (beta).py DELETED
@@ -1,77 +0,0 @@
1
- import os
2
- import importlib
3
- import sys
4
- import pandas as pd
5
- import streamlit as st
6
- from io import BytesIO
7
- from modules.robby_sheet.table_tool import PandasAgent
8
- from modules.layout import Layout
9
- from modules.utils import Utilities
10
- from modules.sidebar import Sidebar
11
-
12
- def reload_module(module_name):
13
- """For update changes
14
- made to modules in localhost (press r)"""
15
-
16
- if module_name in sys.modules:
17
- importlib.reload(sys.modules[module_name])
18
- return sys.modules[module_name]
19
-
20
- table_tool_module = reload_module('modules.robby_sheet.table_tool')
21
- layout_module = reload_module('modules.layout')
22
- utils_module = reload_module('modules.utils')
23
- sidebar_module = reload_module('modules.sidebar')
24
-
25
-
26
- st.set_page_config(layout="wide", page_icon="💬", page_title="Robby | Chat-Bot 🤖")
27
-
28
- layout, sidebar, utils = Layout(), Sidebar(), Utilities()
29
-
30
- layout.show_header("CSV, Excel")
31
-
32
- user_api_key = utils.load_api_key()
33
- os.environ["OPENAI_API_KEY"] = user_api_key
34
-
35
-
36
- if not user_api_key:
37
- layout.show_api_key_missing()
38
-
39
- else:
40
- st.session_state.setdefault("reset_chat", False)
41
-
42
- uploaded_file = utils.handle_upload(["csv", "xlsx"])
43
-
44
- if uploaded_file:
45
- sidebar.about()
46
-
47
- uploaded_file_content = BytesIO(uploaded_file.getvalue())
48
- if uploaded_file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" or uploaded_file.type == "application/vnd.ms-excel":
49
- df = pd.read_excel(uploaded_file_content)
50
- else:
51
- df = pd.read_csv(uploaded_file_content)
52
-
53
- st.session_state.df = df
54
-
55
- if "chat_history" not in st.session_state:
56
- st.session_state["chat_history"] = []
57
- csv_agent = PandasAgent()
58
-
59
- with st.form(key="query"):
60
-
61
- query = st.text_input("Ask [PandasAI](https://github.com/gventuri/pandas-ai) (look the pandas-AI read-me for how use it)", value="", type="default",
62
- placeholder="e-g : How many rows ? "
63
- )
64
- submitted_query = st.form_submit_button("Submit")
65
- reset_chat_button = st.form_submit_button("Reset Chat")
66
- if reset_chat_button:
67
- st.session_state["chat_history"] = []
68
- if submitted_query:
69
- result, captured_output = csv_agent.get_agent_response(df, query)
70
- cleaned_thoughts = csv_agent.process_agent_thoughts(captured_output)
71
- csv_agent.display_agent_thoughts(cleaned_thoughts)
72
- csv_agent.update_chat_history(query, result)
73
- csv_agent.display_chat_history()
74
- if st.session_state.df is not None:
75
- st.subheader("Current dataframe:")
76
- st.write(st.session_state.df)
77
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/CofAI/chat.v1/app.py DELETED
@@ -1,434 +0,0 @@
1
- import io
2
- from fastapi import FastAPI, File, UploadFile
3
-
4
- import subprocess
5
- import os
6
- import requests
7
- import random
8
-
9
- import shutil
10
- import json
11
- # from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
12
- from pydantic import BaseModel
13
- from typing import Annotated
14
-
15
- from fastapi import Form
16
-
17
-
18
- import selenium
19
-
20
- from selenium import webdriver
21
- from selenium.webdriver import ChromeOptions
22
- from selenium.webdriver.chrome.service import Service
23
- import threading
24
- import random
25
- import string
26
- import time
27
-
28
-
29
- # from selenium.webdriver.firefox.options import Options
30
-
31
- # options = FirefoxOptions()
32
- # options.headless = True
33
-
34
- # service = Service()
35
-
36
-
37
- # driver = webdriver.Firefox(options= options,service=service)
38
- # driver.get("https://yuntian-deng-chatgpt.hf.space/")
39
-
40
-
41
-
42
-
43
- # driver.get("https://yuntian-deng-chatgpt.hf.space/")
44
-
45
-
46
- class Query(BaseModel):
47
- text: str
48
- host:str
49
-
50
-
51
-
52
-
53
- from fastapi import FastAPI, Request, Depends, UploadFile, File
54
- from fastapi.exceptions import HTTPException
55
- from fastapi.middleware.cors import CORSMiddleware
56
- from fastapi.responses import JSONResponse
57
-
58
-
59
- app = FastAPI()
60
-
61
- app.add_middleware(
62
- CORSMiddleware,
63
- allow_origins=['*'],
64
- allow_credentials=True,
65
- allow_methods=['*'],
66
- allow_headers=['*'],
67
- )
68
-
69
-
70
- # cred = credentials.Certificate('key.json')
71
- # app1 = firebase_admin.initialize_app(cred)
72
- # db = firestore.client()
73
- # data_frame = pd.read_csv('data.csv')
74
-
75
- from selenium.webdriver.common.by import By
76
- from pymongo.mongo_client import MongoClient
77
-
78
- @app.on_event("startup")
79
- async def startup_event():
80
- print("on startup")
81
-
82
-
83
- # t = threading.Thread(target=makeqimg)
84
- # t.start()
85
-
86
-
87
-
88
-
89
-
90
- mycol = None
91
-
92
-
93
- @app.post("/url")
94
- async def get_url(request: Request ):
95
- return "k"
96
-
97
- # data = await request.json()
98
- # text = data['url']
99
- # mongo_url=text
100
- # print("mongo url ",text)
101
- # global mycol
102
- # if mycol==None:
103
- # myclient = MongoClient(mongo_url)
104
-
105
- # try:
106
- # myclient.admin.command('ping')
107
- # print("Pinged your deployment. You successfully connected to MongoDB!")
108
- # except Exception as e:
109
- # print(e)
110
-
111
- # mydb = myclient['open-ai-api-keys']
112
-
113
- # mycol= mydb['key']
114
- # extract()
115
-
116
-
117
-
118
-
119
- def extract():
120
- options = ChromeOptions()
121
- options.add_argument('--no-sandbox')
122
- options.add_argument('-headless')
123
- service = Service()
124
- driver = webdriver.Chrome(options= options,service=service)
125
-
126
-
127
- global mycol
128
- # global driver
129
-
130
- if True:
131
- # time.sleep(60)
132
- try:
133
- driver.get("https://talkai.info/chat/")
134
- element = driver.find_element(By.CSS_SELECTOR,".chat")
135
- api_key = element.get_attribute("data-api-key")
136
- dict={"key":"open-ai"}
137
- mycol.delete_one(dict)
138
- dict={"key":"open-ai","value":api_key}
139
- mycol.insert_one(dict)
140
- print(api_key)
141
- driver.delete_all_cookies()
142
- driver.quit()
143
-
144
- except Exception as e:
145
- print('error in extract ',e)
146
- pass
147
- # time.sleep(60)
148
-
149
-
150
-
151
- from queue import Queue
152
- chatq = Queue()
153
- imgq= Queue()
154
-
155
-
156
- def makeqchat():
157
-
158
- while chatq.qsize()<2:
159
- print("appending in chat queue")
160
- options = ChromeOptions()
161
- options.add_argument('--no-sandbox')
162
- options.add_argument('-headless')
163
- service = Service()
164
- driver = webdriver.Chrome(options= options,service=service)
165
- driver.get("https://talkai.info/chat/")
166
- chatq.put(driver)
167
-
168
-
169
-
170
- def makeqimg():
171
-
172
- while imgq.qsize()<2:
173
- print("appending in img queue")
174
- options = ChromeOptions()
175
- options.add_argument('--no-sandbox')
176
- options.add_argument('-headless')
177
- service = Service()
178
- driver = webdriver.Chrome(options= options,service=service)
179
- driver.get("https://talkai.info/image/")
180
- imgq.put(driver)
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
- @app.post("/")
189
- async def get_answer(request: Request ):
190
- data = await request.json()
191
-
192
- text = data['text']
193
- host= ''
194
-
195
- temperature=-1
196
-
197
- try:
198
- temperature= data['temperature']
199
- temperature= float(temperature)
200
- temperature= round(temperature,1)
201
-
202
- except:
203
- print("No temperature")
204
-
205
-
206
- # N = 20
207
- # res = ''.join(random.choices(string.ascii_uppercase +
208
- # string.digits, k=N))
209
- # res= res+ str(time.time())
210
-
211
- id= ''
212
-
213
-
214
- # t = threading.Thread(target=do_ML, args=(id,text,host,0))
215
- # t.start()
216
-
217
- res= do_ML(id,text,host,0,temperature)
218
-
219
-
220
- dict={"ChatGPT":res}
221
- # dict= {"id":id}
222
-
223
-
224
- return JSONResponse(dict)
225
-
226
-
227
-
228
-
229
-
230
-
231
- def do_ML(id:str,text:str,host:str, trycount:int,temperature:float):
232
-
233
- try:
234
- starttime=time.time()
235
- options = ChromeOptions()
236
- options.add_argument('--no-sandbox')
237
- options.add_argument('-headless')
238
- service = Service()
239
- driver = webdriver.Chrome(options= options,service=service)
240
- driver.get("https://talkai.info/chat/")
241
- if temperature>=0 and temperature<=2:
242
- try:
243
- print("setting temperature ",temperature)
244
- while True:
245
- currtime= time.time()
246
- if(currtime>starttime+10):
247
- return "Requested Could not be proceed"
248
-
249
- try:
250
- setting_button = driver.find_element(By.ID, "openSettings")
251
- setting_button.click()
252
- break
253
- except:
254
- time.sleep(0.2)
255
-
256
- while True:
257
- currtime= time.time()
258
- if(currtime>starttime+10):
259
- return "Requested Could not be proceed"
260
- try:
261
- input_element = driver.find_element(By.CLASS_NAME,"styled-slider")
262
- new_value = temperature
263
- driver.execute_script("arguments[0].value = arguments[1]", input_element, new_value)
264
- break
265
- except:
266
- time.sleep(0.2)
267
- while True:
268
- currtime= time.time()
269
- if(currtime>starttime+10):
270
- return "Requested Could not be proceed"
271
- try:
272
- confirm_button = driver.find_element(By.CLASS_NAME, "settingsButtonConfirm")
273
- confirm_button.click()
274
- break
275
- except:
276
- time.sleep(0.2)
277
- except:
278
- print("could not set temperature")
279
-
280
-
281
- while True:
282
- currtime= time.time()
283
- if(currtime>starttime+10):
284
- return "Requested Could not be proceed"
285
- try:
286
- textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
287
- textarea.send_keys(text)
288
-
289
- button = driver.find_element(By.CLASS_NAME, "sectionChatFormButton")
290
- button.click()
291
- break
292
- except:
293
- time.sleep(0.2)
294
-
295
-
296
- prev =""
297
-
298
- # time.sleep(2)
299
- while True:
300
- time.sleep(0.2)
301
- currtime= time.time()
302
- if(currtime>starttime+18.5):
303
-
304
- return "Requested Could not be proceed"
305
-
306
- value=""
307
- try:
308
- messages = driver.find_elements(By.CLASS_NAME, 'messageContain')
309
- last_message_contain = messages[len(messages)-2]
310
- value = last_message_contain.text
311
- value = value[8:len(value)]
312
- print(value)
313
- if value=="Please, wait...":
314
- continue
315
- except:
316
- continue
317
-
318
-
319
-
320
- driver.delete_all_cookies()
321
- driver.quit()
322
- return value
323
-
324
-
325
-
326
- except:
327
- print("Error")
328
- driver.delete_all_cookies()
329
- if trycount>3:
330
-
331
- return
332
- driver.quit()
333
- return do_ML(id,text,host,trycount+1)
334
-
335
-
336
-
337
-
338
-
339
-
340
- @app.post("/image")
341
- async def get_answer(q: Query ):
342
-
343
- text = q.text
344
- host= q.host
345
-
346
- # N = 20
347
- # res = ''.join(random.choices(string.ascii_uppercase +
348
- # string.digits, k=N))
349
- # res= res+ str(time.time())
350
-
351
- id= ''
352
-
353
- # t = threading.Thread(target=do_ML2, args=(id,text,host,0))
354
- # t.start()
355
-
356
- url = do_ML2(id,text,host,0)
357
-
358
- dict= {"url":url}
359
-
360
-
361
- # dict= {"id":id}
362
-
363
-
364
- return JSONResponse(dict)
365
-
366
-
367
-
368
-
369
-
370
- def do_ML2(id:str,text:str,host:str, trycount:int):
371
-
372
- try:
373
- starttime=time.time()
374
-
375
- options = ChromeOptions()
376
- options.add_argument('--no-sandbox')
377
- options.add_argument('-headless')
378
- service = Service()
379
- driver = webdriver.Chrome(options= options,service=service)
380
- driver.get("https://talkai.info/image/")
381
- while True:
382
- currtime= time.time()
383
- if(currtime>starttime+10):
384
- return "Requested Could not be proceed"
385
- try:
386
- textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
387
- textarea.send_keys(text)
388
- time.sleep(0.1)
389
- button = driver.find_element(By.CLASS_NAME, "sectionChatFormButton")
390
- button.click()
391
- break
392
- except:
393
- time.sleep(0.2)
394
-
395
- # time.sleep(2)
396
- while True:
397
- currtime= time.time()
398
- if(currtime>starttime+10):
399
- return "Requested Could not be proceed"
400
-
401
- time.sleep(0.2)
402
- currtime= time.time()
403
- if(currtime>starttime+18.5):
404
-
405
- return "Request Could not be proceed"
406
- try:
407
- messages = driver.find_elements(By.XPATH, "//div[@class='messageContain']/p/img")
408
- last_message_contain = messages[len(messages)-2]
409
- src = last_message_contain.get_attribute("src")
410
- print(src)
411
-
412
- driver.delete_all_cookies()
413
- driver.quit()
414
-
415
- return src
416
- break
417
- except:
418
- continue
419
-
420
- except:
421
- print("Error")
422
- driver.delete_all_cookies()
423
- if trycount>1:
424
-
425
- return "Request Could not be proceed"
426
- driver.quit()
427
- return do_ML2(id,text,host,trycount+1)
428
-
429
-
430
-
431
-
432
-
433
-
434
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Cyril666/ContourNet-ABI/app.py DELETED
@@ -1,95 +0,0 @@
1
- import os
2
- os.system('pip install --upgrade --no-cache-dir gdown')
3
- os.system('gdown -O ./model_ctw.pth 16qgtD4UOhp0q5e2RYXE1dvuTz_ylZMyb')
4
- #os.system('unzip model_ctw.zip')
5
- os.system('gdown -O ./workdir.zip 10HxLehcJMY9rLd_OyH40HmrySZItuNDt')
6
- os.system('unzip workdir.zip')
7
- os.system('pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"')
8
- os.system('python setup.py build develop --user')
9
-
10
- import cv2
11
- import pandas as pd
12
- import gradio as gr
13
-
14
- from det_demo import DetDemo
15
- from maskrcnn_benchmark.config import cfg
16
-
17
- from demo import get_model, preprocess, postprocess, load
18
- from utils import Config, Logger, CharsetMapper
19
- import torch
20
-
21
-
22
- def infer(img):
23
- filepath = './input.png'
24
- img.save(filepath)
25
- config = Config('configs/rec/train_abinet.yaml')
26
- config.model_vision_checkpoint = None
27
- model = get_model(config)
28
- model = load(model, 'workdir/train-abinet/best-train-abinet.pth')
29
- charset = CharsetMapper(filename=config.dataset_charset_path, max_length=config.dataset_max_length + 1)
30
-
31
- cfg.merge_from_file('./configs/det/r50_baseline.yaml')
32
- # manual override some options
33
- cfg.merge_from_list(["MODEL.DEVICE", "cpu"])
34
-
35
- det_demo = DetDemo(
36
- cfg,
37
- min_image_size=800,
38
- confidence_threshold=0.7,
39
- output_polygon=True
40
- )
41
-
42
- image = cv2.imread(filepath)
43
- print(image.shape)
44
- result_polygons, result_masks, result_boxes = det_demo.run_on_opencv_image(image)
45
-
46
- patchs = [image[box[1]:box[3], box[0]:box[2], :] for box in result_boxes]
47
- patchs = [preprocess(patch, config.dataset_image_width, config.dataset_image_height) for patch in patchs]
48
- patchs = torch.cat(patchs, dim=0)
49
- res = model(patchs)
50
- result_words = postprocess(res, charset, 'alignment')[0]
51
-
52
- visual_image = det_demo.visualization(image.copy(), result_polygons, result_masks, result_boxes, result_words)
53
-
54
- print(visual_image.shape)
55
- cv2.imwrite('result.jpg', visual_image)
56
- return ['result.jpg', pd.DataFrame(result_words)]
57
-
58
- blocks = gr.Blocks()
59
-
60
- input_image = gr.Image(label="image", type="pil")
61
- output_image = gr.Image(label="out_img", type="filepath")
62
- output_word = gr.Dataframe(label="out_word", headers=['word'])
63
-
64
- with blocks:
65
- gr.Markdown('''
66
- <center><h1 id="title">张博强毕设展示</h1></center>
67
- <center> 西北工业大学 航海学院本科 张博强 </center>
68
- <center> 毕设题目:自然场景中任意形状文字的检测与识别 </center>
69
- <center> 检测:基于<a href="https://github.com/wangyuxin87/ContourNet">ContourNet</a> 识别:基于<a href="https://github.com/FangShancheng/ABINet">ABINet</a> </center>
70
- ''')
71
-
72
- with gr.Row():
73
- with gr.Column():
74
- input_image.render()
75
- button = gr.Button("Submit")
76
- button.click(fn=infer, inputs=[input_image],
77
- outputs=[output_image, output_word],)
78
- with gr.Column():
79
- output_image.render()
80
- with gr.Row():
81
- output_word.render()
82
-
83
-
84
- if __name__ == "__main__":
85
- blocks.launch(debug=True)
86
- '''
87
- iface = gr.Interface(
88
- fn=infer,
89
- title="张博强毕设展示",
90
- description=description,
91
- inputs=[gr.inputs.Image(label="image", type="filepath")],
92
- outputs=[gr.outputs.Image(), gr.outputs.Dataframe(headers=['word'])],
93
- examples=['figs/test/CANDY.png', 'figs/test/ESPLANADE.png', 'figs/test/KAPPA.png'],
94
- ).launch(enable_queue=True, cache_examples=True)
95
- '''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DAMO-NLP-SG/Video-LLaMA/video_llama/common/logger.py DELETED
@@ -1,195 +0,0 @@
1
- """
2
- Copyright (c) 2022, salesforce.com, inc.
3
- All rights reserved.
4
- SPDX-License-Identifier: BSD-3-Clause
5
- For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
- """
7
-
8
- import datetime
9
- import logging
10
- import time
11
- from collections import defaultdict, deque
12
-
13
- import torch
14
- import torch.distributed as dist
15
-
16
- from video_llama.common import dist_utils
17
-
18
-
19
- class SmoothedValue(object):
20
- """Track a series of values and provide access to smoothed values over a
21
- window or the global series average.
22
- """
23
-
24
- def __init__(self, window_size=20, fmt=None):
25
- if fmt is None:
26
- fmt = "{median:.4f} ({global_avg:.4f})"
27
- self.deque = deque(maxlen=window_size)
28
- self.total = 0.0
29
- self.count = 0
30
- self.fmt = fmt
31
-
32
- def update(self, value, n=1):
33
- self.deque.append(value)
34
- self.count += n
35
- self.total += value * n
36
-
37
- def synchronize_between_processes(self):
38
- """
39
- Warning: does not synchronize the deque!
40
- """
41
- if not dist_utils.is_dist_avail_and_initialized():
42
- return
43
- t = torch.tensor([self.count, self.total], dtype=torch.float64, device="cuda")
44
- dist.barrier()
45
- dist.all_reduce(t)
46
- t = t.tolist()
47
- self.count = int(t[0])
48
- self.total = t[1]
49
-
50
- @property
51
- def median(self):
52
- d = torch.tensor(list(self.deque))
53
- return d.median().item()
54
-
55
- @property
56
- def avg(self):
57
- d = torch.tensor(list(self.deque), dtype=torch.float32)
58
- return d.mean().item()
59
-
60
- @property
61
- def global_avg(self):
62
- return self.total / self.count
63
-
64
- @property
65
- def max(self):
66
- return max(self.deque)
67
-
68
- @property
69
- def value(self):
70
- return self.deque[-1]
71
-
72
- def __str__(self):
73
- return self.fmt.format(
74
- median=self.median,
75
- avg=self.avg,
76
- global_avg=self.global_avg,
77
- max=self.max,
78
- value=self.value,
79
- )
80
-
81
-
82
- class MetricLogger(object):
83
- def __init__(self, delimiter="\t"):
84
- self.meters = defaultdict(SmoothedValue)
85
- self.delimiter = delimiter
86
-
87
- def update(self, **kwargs):
88
- for k, v in kwargs.items():
89
- if isinstance(v, torch.Tensor):
90
- v = v.item()
91
- assert isinstance(v, (float, int))
92
- self.meters[k].update(v)
93
-
94
- def __getattr__(self, attr):
95
- if attr in self.meters:
96
- return self.meters[attr]
97
- if attr in self.__dict__:
98
- return self.__dict__[attr]
99
- raise AttributeError(
100
- "'{}' object has no attribute '{}'".format(type(self).__name__, attr)
101
- )
102
-
103
- def __str__(self):
104
- loss_str = []
105
- for name, meter in self.meters.items():
106
- loss_str.append("{}: {}".format(name, str(meter)))
107
- return self.delimiter.join(loss_str)
108
-
109
- def global_avg(self):
110
- loss_str = []
111
- for name, meter in self.meters.items():
112
- loss_str.append("{}: {:.4f}".format(name, meter.global_avg))
113
- return self.delimiter.join(loss_str)
114
-
115
- def synchronize_between_processes(self):
116
- for meter in self.meters.values():
117
- meter.synchronize_between_processes()
118
-
119
- def add_meter(self, name, meter):
120
- self.meters[name] = meter
121
-
122
- def log_every(self, iterable, print_freq, header=None):
123
- i = 0
124
- if not header:
125
- header = ""
126
- start_time = time.time()
127
- end = time.time()
128
- iter_time = SmoothedValue(fmt="{avg:.4f}")
129
- data_time = SmoothedValue(fmt="{avg:.4f}")
130
- space_fmt = ":" + str(len(str(len(iterable)))) + "d"
131
- log_msg = [
132
- header,
133
- "[{0" + space_fmt + "}/{1}]",
134
- "eta: {eta}",
135
- "{meters}",
136
- "time: {time}",
137
- "data: {data}",
138
- ]
139
- if torch.cuda.is_available():
140
- log_msg.append("max mem: {memory:.0f}")
141
- log_msg = self.delimiter.join(log_msg)
142
- MB = 1024.0 * 1024.0
143
- for obj in iterable:
144
- data_time.update(time.time() - end)
145
- yield obj
146
- iter_time.update(time.time() - end)
147
- if i % print_freq == 0 or i == len(iterable) - 1:
148
- eta_seconds = iter_time.global_avg * (len(iterable) - i)
149
- eta_string = str(datetime.timedelta(seconds=int(eta_seconds)))
150
- if torch.cuda.is_available():
151
- print(
152
- log_msg.format(
153
- i,
154
- len(iterable),
155
- eta=eta_string,
156
- meters=str(self),
157
- time=str(iter_time),
158
- data=str(data_time),
159
- memory=torch.cuda.max_memory_allocated() / MB,
160
- )
161
- )
162
- else:
163
- print(
164
- log_msg.format(
165
- i,
166
- len(iterable),
167
- eta=eta_string,
168
- meters=str(self),
169
- time=str(iter_time),
170
- data=str(data_time),
171
- )
172
- )
173
- i += 1
174
- end = time.time()
175
- total_time = time.time() - start_time
176
- total_time_str = str(datetime.timedelta(seconds=int(total_time)))
177
- print(
178
- "{} Total time: {} ({:.4f} s / it)".format(
179
- header, total_time_str, total_time / len(iterable)
180
- )
181
- )
182
-
183
-
184
- class AttrDict(dict):
185
- def __init__(self, *args, **kwargs):
186
- super(AttrDict, self).__init__(*args, **kwargs)
187
- self.__dict__ = self
188
-
189
-
190
- def setup_logger():
191
- logging.basicConfig(
192
- level=logging.INFO if dist_utils.is_main_process() else logging.WARN,
193
- format="%(asctime)s [%(levelname)s] %(message)s",
194
- handlers=[logging.StreamHandler()],
195
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DEBO-PROJECT/DEBO-V1/modules/query_modules.py DELETED
@@ -1,53 +0,0 @@
1
- from time import time
2
- from datetime import datetime
3
-
4
- # modules
5
- from modules.db_modules import put_item
6
- from modules.history_modules import get_history
7
-
8
- # bots
9
- from bots.debate_bot import debate_bot
10
-
11
-
12
- def query(
13
- db_table,
14
- user_id,
15
- prompt,
16
- debate_subject,
17
- bot_role,
18
- session_num
19
- ):
20
-
21
- print("query session", session_num)
22
-
23
- history, history_num = get_history(
24
- db_table,
25
- name_of_partition_key="user_id",
26
- value_of_partition_key=user_id,
27
- session_num=session_num
28
- )
29
- print("history", history)
30
-
31
- bot_result = debate_bot(
32
- prompt,
33
- history,
34
- debate_subject,
35
- bot_role,
36
- history_num
37
- )
38
-
39
- time_stamp = str(datetime.fromtimestamp(time()))
40
-
41
- item = {
42
- 'user_id': user_id,
43
- 'time_stamp': time_stamp,
44
- 'user_prompt': prompt,
45
- 'bot_response': bot_result,
46
- 'debate_subject': debate_subject,
47
- 'session_num': session_num,
48
- 'bot_role': bot_role
49
- }
50
-
51
- put_item(db_table, item)
52
-
53
- return bot_result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/PIL/PcfFontFile.py DELETED
@@ -1,256 +0,0 @@
1
- #
2
- # THIS IS WORK IN PROGRESS
3
- #
4
- # The Python Imaging Library
5
- # $Id$
6
- #
7
- # portable compiled font file parser
8
- #
9
- # history:
10
- # 1997-08-19 fl created
11
- # 2003-09-13 fl fixed loading of unicode fonts
12
- #
13
- # Copyright (c) 1997-2003 by Secret Labs AB.
14
- # Copyright (c) 1997-2003 by Fredrik Lundh.
15
- #
16
- # See the README file for information on usage and redistribution.
17
- #
18
-
19
- import io
20
-
21
- from . import FontFile, Image
22
- from ._binary import i8
23
- from ._binary import i16be as b16
24
- from ._binary import i16le as l16
25
- from ._binary import i32be as b32
26
- from ._binary import i32le as l32
27
-
28
- # --------------------------------------------------------------------
29
- # declarations
30
-
31
- PCF_MAGIC = 0x70636601 # "\x01fcp"
32
-
33
- PCF_PROPERTIES = 1 << 0
34
- PCF_ACCELERATORS = 1 << 1
35
- PCF_METRICS = 1 << 2
36
- PCF_BITMAPS = 1 << 3
37
- PCF_INK_METRICS = 1 << 4
38
- PCF_BDF_ENCODINGS = 1 << 5
39
- PCF_SWIDTHS = 1 << 6
40
- PCF_GLYPH_NAMES = 1 << 7
41
- PCF_BDF_ACCELERATORS = 1 << 8
42
-
43
- BYTES_PER_ROW = [
44
- lambda bits: ((bits + 7) >> 3),
45
- lambda bits: ((bits + 15) >> 3) & ~1,
46
- lambda bits: ((bits + 31) >> 3) & ~3,
47
- lambda bits: ((bits + 63) >> 3) & ~7,
48
- ]
49
-
50
-
51
- def sz(s, o):
52
- return s[o : s.index(b"\0", o)]
53
-
54
-
55
- class PcfFontFile(FontFile.FontFile):
56
- """Font file plugin for the X11 PCF format."""
57
-
58
- name = "name"
59
-
60
- def __init__(self, fp, charset_encoding="iso8859-1"):
61
- self.charset_encoding = charset_encoding
62
-
63
- magic = l32(fp.read(4))
64
- if magic != PCF_MAGIC:
65
- msg = "not a PCF file"
66
- raise SyntaxError(msg)
67
-
68
- super().__init__()
69
-
70
- count = l32(fp.read(4))
71
- self.toc = {}
72
- for i in range(count):
73
- type = l32(fp.read(4))
74
- self.toc[type] = l32(fp.read(4)), l32(fp.read(4)), l32(fp.read(4))
75
-
76
- self.fp = fp
77
-
78
- self.info = self._load_properties()
79
-
80
- metrics = self._load_metrics()
81
- bitmaps = self._load_bitmaps(metrics)
82
- encoding = self._load_encoding()
83
-
84
- #
85
- # create glyph structure
86
-
87
- for ch, ix in enumerate(encoding):
88
- if ix is not None:
89
- (
90
- xsize,
91
- ysize,
92
- left,
93
- right,
94
- width,
95
- ascent,
96
- descent,
97
- attributes,
98
- ) = metrics[ix]
99
- self.glyph[ch] = (
100
- (width, 0),
101
- (left, descent - ysize, xsize + left, descent),
102
- (0, 0, xsize, ysize),
103
- bitmaps[ix],
104
- )
105
-
106
- def _getformat(self, tag):
107
- format, size, offset = self.toc[tag]
108
-
109
- fp = self.fp
110
- fp.seek(offset)
111
-
112
- format = l32(fp.read(4))
113
-
114
- if format & 4:
115
- i16, i32 = b16, b32
116
- else:
117
- i16, i32 = l16, l32
118
-
119
- return fp, format, i16, i32
120
-
121
- def _load_properties(self):
122
- #
123
- # font properties
124
-
125
- properties = {}
126
-
127
- fp, format, i16, i32 = self._getformat(PCF_PROPERTIES)
128
-
129
- nprops = i32(fp.read(4))
130
-
131
- # read property description
132
- p = []
133
- for i in range(nprops):
134
- p.append((i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))))
135
- if nprops & 3:
136
- fp.seek(4 - (nprops & 3), io.SEEK_CUR) # pad
137
-
138
- data = fp.read(i32(fp.read(4)))
139
-
140
- for k, s, v in p:
141
- k = sz(data, k)
142
- if s:
143
- v = sz(data, v)
144
- properties[k] = v
145
-
146
- return properties
147
-
148
- def _load_metrics(self):
149
- #
150
- # font metrics
151
-
152
- metrics = []
153
-
154
- fp, format, i16, i32 = self._getformat(PCF_METRICS)
155
-
156
- append = metrics.append
157
-
158
- if (format & 0xFF00) == 0x100:
159
- # "compressed" metrics
160
- for i in range(i16(fp.read(2))):
161
- left = i8(fp.read(1)) - 128
162
- right = i8(fp.read(1)) - 128
163
- width = i8(fp.read(1)) - 128
164
- ascent = i8(fp.read(1)) - 128
165
- descent = i8(fp.read(1)) - 128
166
- xsize = right - left
167
- ysize = ascent + descent
168
- append((xsize, ysize, left, right, width, ascent, descent, 0))
169
-
170
- else:
171
- # "jumbo" metrics
172
- for i in range(i32(fp.read(4))):
173
- left = i16(fp.read(2))
174
- right = i16(fp.read(2))
175
- width = i16(fp.read(2))
176
- ascent = i16(fp.read(2))
177
- descent = i16(fp.read(2))
178
- attributes = i16(fp.read(2))
179
- xsize = right - left
180
- ysize = ascent + descent
181
- append((xsize, ysize, left, right, width, ascent, descent, attributes))
182
-
183
- return metrics
184
-
185
- def _load_bitmaps(self, metrics):
186
- #
187
- # bitmap data
188
-
189
- bitmaps = []
190
-
191
- fp, format, i16, i32 = self._getformat(PCF_BITMAPS)
192
-
193
- nbitmaps = i32(fp.read(4))
194
-
195
- if nbitmaps != len(metrics):
196
- msg = "Wrong number of bitmaps"
197
- raise OSError(msg)
198
-
199
- offsets = []
200
- for i in range(nbitmaps):
201
- offsets.append(i32(fp.read(4)))
202
-
203
- bitmap_sizes = []
204
- for i in range(4):
205
- bitmap_sizes.append(i32(fp.read(4)))
206
-
207
- # byteorder = format & 4 # non-zero => MSB
208
- bitorder = format & 8 # non-zero => MSB
209
- padindex = format & 3
210
-
211
- bitmapsize = bitmap_sizes[padindex]
212
- offsets.append(bitmapsize)
213
-
214
- data = fp.read(bitmapsize)
215
-
216
- pad = BYTES_PER_ROW[padindex]
217
- mode = "1;R"
218
- if bitorder:
219
- mode = "1"
220
-
221
- for i in range(nbitmaps):
222
- xsize, ysize = metrics[i][:2]
223
- b, e = offsets[i : i + 2]
224
- bitmaps.append(
225
- Image.frombytes("1", (xsize, ysize), data[b:e], "raw", mode, pad(xsize))
226
- )
227
-
228
- return bitmaps
229
-
230
- def _load_encoding(self):
231
- fp, format, i16, i32 = self._getformat(PCF_BDF_ENCODINGS)
232
-
233
- first_col, last_col = i16(fp.read(2)), i16(fp.read(2))
234
- first_row, last_row = i16(fp.read(2)), i16(fp.read(2))
235
-
236
- i16(fp.read(2)) # default
237
-
238
- nencoding = (last_col - first_col + 1) * (last_row - first_row + 1)
239
-
240
- # map character code to bitmap index
241
- encoding = [None] * min(256, nencoding)
242
-
243
- encoding_offsets = [i16(fp.read(2)) for _ in range(nencoding)]
244
-
245
- for i in range(first_col, len(encoding)):
246
- try:
247
- encoding_offset = encoding_offsets[
248
- ord(bytearray([i]).decode(self.charset_encoding))
249
- ]
250
- if encoding_offset != 0xFFFF:
251
- encoding[i] = encoding_offset
252
- except UnicodeDecodeError:
253
- # character is not supported in selected encoding
254
- pass
255
-
256
- return encoding
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/cu2qu/ufo.py DELETED
@@ -1,349 +0,0 @@
1
- # Copyright 2015 Google Inc. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- """Converts cubic bezier curves to quadratic splines.
17
-
18
- Conversion is performed such that the quadratic splines keep the same end-curve
19
- tangents as the original cubics. The approach is iterative, increasing the
20
- number of segments for a spline until the error gets below a bound.
21
-
22
- Respective curves from multiple fonts will be converted at once to ensure that
23
- the resulting splines are interpolation-compatible.
24
- """
25
-
26
- import logging
27
- from fontTools.pens.basePen import AbstractPen
28
- from fontTools.pens.pointPen import PointToSegmentPen
29
- from fontTools.pens.reverseContourPen import ReverseContourPen
30
-
31
- from . import curves_to_quadratic
32
- from .errors import (
33
- UnequalZipLengthsError,
34
- IncompatibleSegmentNumberError,
35
- IncompatibleSegmentTypesError,
36
- IncompatibleGlyphsError,
37
- IncompatibleFontsError,
38
- )
39
-
40
-
41
- __all__ = ["fonts_to_quadratic", "font_to_quadratic"]
42
-
43
- # The default approximation error below is a relative value (1/1000 of the EM square).
44
- # Later on, we convert it to absolute font units by multiplying it by a font's UPEM
45
- # (see fonts_to_quadratic).
46
- DEFAULT_MAX_ERR = 0.001
47
- CURVE_TYPE_LIB_KEY = "com.github.googlei18n.cu2qu.curve_type"
48
-
49
- logger = logging.getLogger(__name__)
50
-
51
-
52
- _zip = zip
53
-
54
-
55
- def zip(*args):
56
- """Ensure each argument to zip has the same length. Also make sure a list is
57
- returned for python 2/3 compatibility.
58
- """
59
-
60
- if len(set(len(a) for a in args)) != 1:
61
- raise UnequalZipLengthsError(*args)
62
- return list(_zip(*args))
63
-
64
-
65
- class GetSegmentsPen(AbstractPen):
66
- """Pen to collect segments into lists of points for conversion.
67
-
68
- Curves always include their initial on-curve point, so some points are
69
- duplicated between segments.
70
- """
71
-
72
- def __init__(self):
73
- self._last_pt = None
74
- self.segments = []
75
-
76
- def _add_segment(self, tag, *args):
77
- if tag in ["move", "line", "qcurve", "curve"]:
78
- self._last_pt = args[-1]
79
- self.segments.append((tag, args))
80
-
81
- def moveTo(self, pt):
82
- self._add_segment("move", pt)
83
-
84
- def lineTo(self, pt):
85
- self._add_segment("line", pt)
86
-
87
- def qCurveTo(self, *points):
88
- self._add_segment("qcurve", self._last_pt, *points)
89
-
90
- def curveTo(self, *points):
91
- self._add_segment("curve", self._last_pt, *points)
92
-
93
- def closePath(self):
94
- self._add_segment("close")
95
-
96
- def endPath(self):
97
- self._add_segment("end")
98
-
99
- def addComponent(self, glyphName, transformation):
100
- pass
101
-
102
-
103
- def _get_segments(glyph):
104
- """Get a glyph's segments as extracted by GetSegmentsPen."""
105
-
106
- pen = GetSegmentsPen()
107
- # glyph.draw(pen)
108
- # We can't simply draw the glyph with the pen, but we must initialize the
109
- # PointToSegmentPen explicitly with outputImpliedClosingLine=True.
110
- # By default PointToSegmentPen does not outputImpliedClosingLine -- unless
111
- # last and first point on closed contour are duplicated. Because we are
112
- # converting multiple glyphs at the same time, we want to make sure
113
- # this function returns the same number of segments, whether or not
114
- # the last and first point overlap.
115
- # https://github.com/googlefonts/fontmake/issues/572
116
- # https://github.com/fonttools/fonttools/pull/1720
117
- pointPen = PointToSegmentPen(pen, outputImpliedClosingLine=True)
118
- glyph.drawPoints(pointPen)
119
- return pen.segments
120
-
121
-
122
- def _set_segments(glyph, segments, reverse_direction):
123
- """Draw segments as extracted by GetSegmentsPen back to a glyph."""
124
-
125
- glyph.clearContours()
126
- pen = glyph.getPen()
127
- if reverse_direction:
128
- pen = ReverseContourPen(pen)
129
- for tag, args in segments:
130
- if tag == "move":
131
- pen.moveTo(*args)
132
- elif tag == "line":
133
- pen.lineTo(*args)
134
- elif tag == "curve":
135
- pen.curveTo(*args[1:])
136
- elif tag == "qcurve":
137
- pen.qCurveTo(*args[1:])
138
- elif tag == "close":
139
- pen.closePath()
140
- elif tag == "end":
141
- pen.endPath()
142
- else:
143
- raise AssertionError('Unhandled segment type "%s"' % tag)
144
-
145
-
146
- def _segments_to_quadratic(segments, max_err, stats, all_quadratic=True):
147
- """Return quadratic approximations of cubic segments."""
148
-
149
- assert all(s[0] == "curve" for s in segments), "Non-cubic given to convert"
150
-
151
- new_points = curves_to_quadratic([s[1] for s in segments], max_err, all_quadratic)
152
- n = len(new_points[0])
153
- assert all(len(s) == n for s in new_points[1:]), "Converted incompatibly"
154
-
155
- spline_length = str(n - 2)
156
- stats[spline_length] = stats.get(spline_length, 0) + 1
157
-
158
- if all_quadratic or n == 3:
159
- return [("qcurve", p) for p in new_points]
160
- else:
161
- return [("curve", p) for p in new_points]
162
-
163
-
164
- def _glyphs_to_quadratic(glyphs, max_err, reverse_direction, stats, all_quadratic=True):
165
- """Do the actual conversion of a set of compatible glyphs, after arguments
166
- have been set up.
167
-
168
- Return True if the glyphs were modified, else return False.
169
- """
170
-
171
- try:
172
- segments_by_location = zip(*[_get_segments(g) for g in glyphs])
173
- except UnequalZipLengthsError:
174
- raise IncompatibleSegmentNumberError(glyphs)
175
- if not any(segments_by_location):
176
- return False
177
-
178
- # always modify input glyphs if reverse_direction is True
179
- glyphs_modified = reverse_direction
180
-
181
- new_segments_by_location = []
182
- incompatible = {}
183
- for i, segments in enumerate(segments_by_location):
184
- tag = segments[0][0]
185
- if not all(s[0] == tag for s in segments[1:]):
186
- incompatible[i] = [s[0] for s in segments]
187
- elif tag == "curve":
188
- new_segments = _segments_to_quadratic(
189
- segments, max_err, stats, all_quadratic
190
- )
191
- if all_quadratic or new_segments != segments:
192
- glyphs_modified = True
193
- segments = new_segments
194
- new_segments_by_location.append(segments)
195
-
196
- if glyphs_modified:
197
- new_segments_by_glyph = zip(*new_segments_by_location)
198
- for glyph, new_segments in zip(glyphs, new_segments_by_glyph):
199
- _set_segments(glyph, new_segments, reverse_direction)
200
-
201
- if incompatible:
202
- raise IncompatibleSegmentTypesError(glyphs, segments=incompatible)
203
- return glyphs_modified
204
-
205
-
206
- def glyphs_to_quadratic(
207
- glyphs, max_err=None, reverse_direction=False, stats=None, all_quadratic=True
208
- ):
209
- """Convert the curves of a set of compatible of glyphs to quadratic.
210
-
211
- All curves will be converted to quadratic at once, ensuring interpolation
212
- compatibility. If this is not required, calling glyphs_to_quadratic with one
213
- glyph at a time may yield slightly more optimized results.
214
-
215
- Return True if glyphs were modified, else return False.
216
-
217
- Raises IncompatibleGlyphsError if glyphs have non-interpolatable outlines.
218
- """
219
- if stats is None:
220
- stats = {}
221
-
222
- if not max_err:
223
- # assume 1000 is the default UPEM
224
- max_err = DEFAULT_MAX_ERR * 1000
225
-
226
- if isinstance(max_err, (list, tuple)):
227
- max_errors = max_err
228
- else:
229
- max_errors = [max_err] * len(glyphs)
230
- assert len(max_errors) == len(glyphs)
231
-
232
- return _glyphs_to_quadratic(
233
- glyphs, max_errors, reverse_direction, stats, all_quadratic
234
- )
235
-
236
-
237
- def fonts_to_quadratic(
238
- fonts,
239
- max_err_em=None,
240
- max_err=None,
241
- reverse_direction=False,
242
- stats=None,
243
- dump_stats=False,
244
- remember_curve_type=True,
245
- all_quadratic=True,
246
- ):
247
- """Convert the curves of a collection of fonts to quadratic.
248
-
249
- All curves will be converted to quadratic at once, ensuring interpolation
250
- compatibility. If this is not required, calling fonts_to_quadratic with one
251
- font at a time may yield slightly more optimized results.
252
-
253
- Return True if fonts were modified, else return False.
254
-
255
- By default, cu2qu stores the curve type in the fonts' lib, under a private
256
- key "com.github.googlei18n.cu2qu.curve_type", and will not try to convert
257
- them again if the curve type is already set to "quadratic".
258
- Setting 'remember_curve_type' to False disables this optimization.
259
-
260
- Raises IncompatibleFontsError if same-named glyphs from different fonts
261
- have non-interpolatable outlines.
262
- """
263
-
264
- if remember_curve_type:
265
- curve_types = {f.lib.get(CURVE_TYPE_LIB_KEY, "cubic") for f in fonts}
266
- if len(curve_types) == 1:
267
- curve_type = next(iter(curve_types))
268
- if curve_type in ("quadratic", "mixed"):
269
- logger.info("Curves already converted to quadratic")
270
- return False
271
- elif curve_type == "cubic":
272
- pass # keep converting
273
- else:
274
- raise NotImplementedError(curve_type)
275
- elif len(curve_types) > 1:
276
- # going to crash later if they do differ
277
- logger.warning("fonts may contain different curve types")
278
-
279
- if stats is None:
280
- stats = {}
281
-
282
- if max_err_em and max_err:
283
- raise TypeError("Only one of max_err and max_err_em can be specified.")
284
- if not (max_err_em or max_err):
285
- max_err_em = DEFAULT_MAX_ERR
286
-
287
- if isinstance(max_err, (list, tuple)):
288
- assert len(max_err) == len(fonts)
289
- max_errors = max_err
290
- elif max_err:
291
- max_errors = [max_err] * len(fonts)
292
-
293
- if isinstance(max_err_em, (list, tuple)):
294
- assert len(fonts) == len(max_err_em)
295
- max_errors = [f.info.unitsPerEm * e for f, e in zip(fonts, max_err_em)]
296
- elif max_err_em:
297
- max_errors = [f.info.unitsPerEm * max_err_em for f in fonts]
298
-
299
- modified = False
300
- glyph_errors = {}
301
- for name in set().union(*(f.keys() for f in fonts)):
302
- glyphs = []
303
- cur_max_errors = []
304
- for font, error in zip(fonts, max_errors):
305
- if name in font:
306
- glyphs.append(font[name])
307
- cur_max_errors.append(error)
308
- try:
309
- modified |= _glyphs_to_quadratic(
310
- glyphs, cur_max_errors, reverse_direction, stats, all_quadratic
311
- )
312
- except IncompatibleGlyphsError as exc:
313
- logger.error(exc)
314
- glyph_errors[name] = exc
315
-
316
- if glyph_errors:
317
- raise IncompatibleFontsError(glyph_errors)
318
-
319
- if modified and dump_stats:
320
- spline_lengths = sorted(stats.keys())
321
- logger.info(
322
- "New spline lengths: %s"
323
- % (", ".join("%s: %d" % (l, stats[l]) for l in spline_lengths))
324
- )
325
-
326
- if remember_curve_type:
327
- for font in fonts:
328
- curve_type = font.lib.get(CURVE_TYPE_LIB_KEY, "cubic")
329
- new_curve_type = "quadratic" if all_quadratic else "mixed"
330
- if curve_type != new_curve_type:
331
- font.lib[CURVE_TYPE_LIB_KEY] = new_curve_type
332
- modified = True
333
- return modified
334
-
335
-
336
- def glyph_to_quadratic(glyph, **kwargs):
337
- """Convenience wrapper around glyphs_to_quadratic, for just one glyph.
338
- Return True if the glyph was modified, else return False.
339
- """
340
-
341
- return glyphs_to_quadratic([glyph], **kwargs)
342
-
343
-
344
- def font_to_quadratic(font, **kwargs):
345
- """Convenience wrapper around fonts_to_quadratic, for just one font.
346
- Return True if the font was modified, else return False.
347
- """
348
-
349
- return fonts_to_quadratic([font], **kwargs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/networking.py DELETED
@@ -1,208 +0,0 @@
1
- """
2
- Defines helper methods useful for setting up ports, launching servers, and
3
- creating tunnels.
4
- """
5
- from __future__ import annotations
6
-
7
- import os
8
- import socket
9
- import threading
10
- import time
11
- import warnings
12
- from typing import TYPE_CHECKING
13
-
14
- import requests
15
- import uvicorn
16
-
17
- from gradio.exceptions import ServerFailedToStartError
18
- from gradio.routes import App
19
- from gradio.tunneling import Tunnel
20
-
21
- if TYPE_CHECKING: # Only import for type checking (to avoid circular imports).
22
- from gradio.blocks import Blocks
23
-
24
- # By default, the local server will try to open on localhost, port 7860.
25
- # If that is not available, then it will try 7861, 7862, ... 7959.
26
- INITIAL_PORT_VALUE = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
27
- TRY_NUM_PORTS = int(os.getenv("GRADIO_NUM_PORTS", "100"))
28
- LOCALHOST_NAME = os.getenv("GRADIO_SERVER_NAME", "127.0.0.1")
29
- GRADIO_API_SERVER = "https://api.gradio.app/v2/tunnel-request"
30
-
31
-
32
- class Server(uvicorn.Server):
33
- def install_signal_handlers(self):
34
- pass
35
-
36
- def run_in_thread(self):
37
- self.thread = threading.Thread(target=self.run, daemon=True)
38
- self.thread.start()
39
- start = time.time()
40
- while not self.started:
41
- time.sleep(1e-3)
42
- if time.time() - start > 5:
43
- raise ServerFailedToStartError(
44
- "Server failed to start. Please check that the port is available."
45
- )
46
-
47
- def close(self):
48
- self.should_exit = True
49
- self.thread.join()
50
-
51
-
52
- def get_first_available_port(initial: int, final: int) -> int:
53
- """
54
- Gets the first open port in a specified range of port numbers
55
- Parameters:
56
- initial: the initial value in the range of port numbers
57
- final: final (exclusive) value in the range of port numbers, should be greater than `initial`
58
- Returns:
59
- port: the first open port in the range
60
- """
61
- for port in range(initial, final):
62
- try:
63
- s = socket.socket() # create a socket object
64
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
65
- s.bind((LOCALHOST_NAME, port)) # Bind to the port
66
- s.close()
67
- return port
68
- except OSError:
69
- pass
70
- raise OSError(
71
- f"All ports from {initial} to {final - 1} are in use. Please close a port."
72
- )
73
-
74
-
75
- def configure_app(app: App, blocks: Blocks) -> App:
76
- auth = blocks.auth
77
- if auth is not None:
78
- if not callable(auth):
79
- app.auth = {account[0]: account[1] for account in auth}
80
- else:
81
- app.auth = auth
82
- else:
83
- app.auth = None
84
- app.blocks = blocks
85
- app.cwd = os.getcwd()
86
- app.favicon_path = blocks.favicon_path
87
- app.tokens = {}
88
- return app
89
-
90
-
91
- def start_server(
92
- blocks: Blocks,
93
- server_name: str | None = None,
94
- server_port: int | None = None,
95
- ssl_keyfile: str | None = None,
96
- ssl_certfile: str | None = None,
97
- ssl_keyfile_password: str | None = None,
98
- app_kwargs: dict | None = None,
99
- ) -> tuple[str, int, str, App, Server]:
100
- """Launches a local server running the provided Interface
101
- Parameters:
102
- blocks: The Blocks object to run on the server
103
- server_name: to make app accessible on local network, set this to "0.0.0.0". Can be set by environment variable GRADIO_SERVER_NAME.
104
- server_port: will start gradio app on this port (if available). Can be set by environment variable GRADIO_SERVER_PORT.
105
- auth: If provided, username and password (or list of username-password tuples) required to access the Blocks. Can also provide function that takes username and password and returns True if valid login.
106
- ssl_keyfile: If a path to a file is provided, will use this as the private key file to create a local server running on https.
107
- ssl_certfile: If a path to a file is provided, will use this as the signed certificate for https. Needs to be provided if ssl_keyfile is provided.
108
- ssl_keyfile_password: If a password is provided, will use this with the ssl certificate for https.
109
- app_kwargs: Additional keyword arguments to pass to the gradio.routes.App constructor.
110
-
111
- Returns:
112
- port: the port number the server is running on
113
- path_to_local_server: the complete address that the local server can be accessed at
114
- app: the FastAPI app object
115
- server: the server object that is a subclass of uvicorn.Server (used to close the server)
116
- """
117
- if ssl_keyfile is not None and ssl_certfile is None:
118
- raise ValueError("ssl_certfile must be provided if ssl_keyfile is provided.")
119
-
120
- server_name = server_name or LOCALHOST_NAME
121
- url_host_name = "localhost" if server_name == "0.0.0.0" else server_name
122
-
123
- # Strip IPv6 brackets from the address if they exist.
124
- # This is needed as http://[::1]:port/ is a valid browser address,
125
- # but not a valid IPv6 address, so asyncio will throw an exception.
126
- if server_name.startswith("[") and server_name.endswith("]"):
127
- host = server_name[1:-1]
128
- else:
129
- host = server_name
130
-
131
- app = App.create_app(blocks, app_kwargs=app_kwargs)
132
-
133
- server_ports = (
134
- [server_port]
135
- if server_port is not None
136
- else range(INITIAL_PORT_VALUE, INITIAL_PORT_VALUE + TRY_NUM_PORTS)
137
- )
138
-
139
- for port in server_ports:
140
- try:
141
- # The fastest way to check if a port is available is to try to bind to it with socket.
142
- # If the port is not available, socket will throw an OSError.
143
- s = socket.socket()
144
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
145
- # Really, we should be checking if (server_name, server_port) is available, but
146
- # socket.bind() doesn't seem to throw an OSError with ipv6 addresses, based on my testing.
147
- # Instead, we just check if the port is available on localhost.
148
- s.bind((LOCALHOST_NAME, port))
149
- s.close()
150
-
151
- # To avoid race conditions, so we also check if the port by trying to start the uvicorn server.
152
- # If the port is not available, this will throw a ServerFailedToStartError.
153
- config = uvicorn.Config(
154
- app=app,
155
- port=port,
156
- host=host,
157
- log_level="warning",
158
- ssl_keyfile=ssl_keyfile,
159
- ssl_certfile=ssl_certfile,
160
- ssl_keyfile_password=ssl_keyfile_password,
161
- ws_max_size=1024 * 1024 * 1024, # Setting max websocket size to be 1 GB
162
- )
163
- server = Server(config=config)
164
- server.run_in_thread()
165
- break
166
- except (OSError, ServerFailedToStartError):
167
- pass
168
- else:
169
- raise OSError(
170
- f"Cannot find empty port in range: {min(server_ports)}-{max(server_ports)}. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the `server_port` parameter to `launch()`."
171
- )
172
-
173
- if ssl_keyfile is not None:
174
- path_to_local_server = f"https://{url_host_name}:{port}/"
175
- else:
176
- path_to_local_server = f"http://{url_host_name}:{port}/"
177
-
178
- return server_name, port, path_to_local_server, app, server
179
-
180
-
181
- def setup_tunnel(local_host: str, local_port: int, share_token: str) -> str:
182
- response = requests.get(GRADIO_API_SERVER)
183
- if response and response.status_code == 200:
184
- try:
185
- payload = response.json()[0]
186
- remote_host, remote_port = payload["host"], int(payload["port"])
187
- tunnel = Tunnel(
188
- remote_host, remote_port, local_host, local_port, share_token
189
- )
190
- address = tunnel.start_tunnel()
191
- return address
192
- except Exception as e:
193
- raise RuntimeError(str(e)) from e
194
- raise RuntimeError("Could not get share link from Gradio API Server.")
195
-
196
-
197
- def url_ok(url: str) -> bool:
198
- try:
199
- for _ in range(5):
200
- with warnings.catch_warnings():
201
- warnings.filterwarnings("ignore")
202
- r = requests.head(url, timeout=3, verify=False)
203
- if r.status_code in (200, 401, 302): # 401 or 302 if auth is set
204
- return True
205
- time.sleep(0.500)
206
- except (ConnectionError, requests.exceptions.ConnectionError):
207
- return False
208
- return False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/templates/cdn/assets/shell-86dd1d99.js DELETED
@@ -1,2 +0,0 @@
1
- var c={};function s(n,e){for(var r=0;r<e.length;r++)c[e[r]]=n}var k=["true","false"],h=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],p=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];s("atom",k);s("keyword",h);s("builtin",p);function d(n,e){if(n.eatSpace())return null;var r=n.sol(),t=n.next();if(t==="\\")return n.next(),null;if(t==="'"||t==='"'||t==="`")return e.tokens.unshift(l(t,t==="`"?"quote":"string")),u(n,e);if(t==="#")return r&&n.eat("!")?(n.skipToEnd(),"meta"):(n.skipToEnd(),"comment");if(t==="$")return e.tokens.unshift(a),u(n,e);if(t==="+"||t==="=")return"operator";if(t==="-")return n.eat("-"),n.eatWhile(/\w/),"attribute";if(t=="<"){if(n.match("<<"))return"operator";var o=n.match(/^<-?\s*['"]?([^'"]*)['"]?/);if(o)return e.tokens.unshift(w(o[1])),"string.special"}if(/\d/.test(t)&&(n.eatWhile(/\d/),n.eol()||!/\w/.test(n.peek())))return"number";n.eatWhile(/[\w-]/);var i=n.current();return n.peek()==="="&&/\w+/.test(i)?"def":c.hasOwnProperty(i)?c[i]:null}function l(n,e){var r=n=="("?")":n=="{"?"}":n;return function(t,o){for(var i,f=!1;(i=t.next())!=null;){if(i===r&&!f){o.tokens.shift();break}else if(i==="$"&&!f&&n!=="'"&&t.peek()!=r){f=!0,t.backUp(1),o.tokens.unshift(a);break}else{if(!f&&n!==r&&i===n)return o.tokens.unshift(l(n,e)),u(t,o);if(!f&&/['"]/.test(i)&&!/['"]/.test(n)){o.tokens.unshift(g(i,"string")),t.backUp(1);break}}f=!f&&i==="\\"}return e}}function g(n,e){return function(r,t){return t.tokens[0]=l(n,e),r.next(),u(r,t)}}var a=function(n,e){e.tokens.length>1&&n.eat("$");var r=n.next();return/['"({]/.test(r)?(e.tokens[0]=l(r,r=="("?"quote":r=="{"?"def":"string"),u(n,e)):(/\d/.test(r)||n.eatWhile(/\w/),e.tokens.shift(),"def")};function w(n){return function(e,r){return e.sol()&&e.string==n&&r.tokens.shift(),e.skipToEnd(),"string.special"}}function u(n,e){return(e.tokens[0]||d)(n,e)}const v={name:"shell",startState:function(){return{tokens:[]}},token:function(n,e){return u(n,e)},languageData:{autocomplete:k.concat(h,p),closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"#"}}};export{v as shell};
2
- //# sourceMappingURL=shell-86dd1d99.js.map
 
 
 
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/gradio/templates/frontend/assets/UploadText-690664d1.css DELETED
@@ -1 +0,0 @@
1
- .wrap.svelte-1ck5uk8{display:flex;flex-direction:column;justify-content:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md)}.or.svelte-1ck5uk8{color:var(--body-text-color-subdued)}@media (min-width: 768px){.wrap.svelte-1ck5uk8{font-size:var(--text-lg)}}
 
 
spaces/Dao3/OpenArt/app.py DELETED
@@ -1,154 +0,0 @@
1
- import gradio as gr
2
- import os
3
- import sys
4
- from pathlib import Path
5
- import random
6
- import string
7
- import time
8
- from queue import Queue
9
- from threading import Thread
10
- import emoji
11
-
12
-
13
- text_gen=gr.Interface.load("spaces/Dao3/MagicPrompt-Stable-Diffusion")
14
- def get_prompts(prompt_text):
15
- if prompt_text:
16
- return text_gen("openjourneyart, " + prompt_text)
17
- else:
18
- return text_gen("")
19
- proc1=gr.Interface.load("models/prompthero/openjourney")
20
-
21
- def restart_script_periodically():
22
- while True:
23
- random_time = random.randint(540, 600)
24
- time.sleep(random_time)
25
- os.execl(sys.executable, sys.executable, *sys.argv)
26
-
27
-
28
- restart_thread = Thread(target=restart_script_periodically, daemon=True)
29
- restart_thread.start()
30
-
31
-
32
- queue = Queue()
33
- queue_threshold = 100
34
-
35
- def add_random_noise(prompt, noise_level=0.00):
36
- if noise_level == 0:
37
- noise_level = 0.00
38
- percentage_noise = noise_level * 5
39
- num_noise_chars = int(len(prompt) * (percentage_noise/100))
40
- noise_indices = random.sample(range(len(prompt)), num_noise_chars)
41
- prompt_list = list(prompt)
42
- noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
43
- noise_chars.extend(['😍', '💩', '😂', '🤔', '😊', '🤗', '😭', '🙄', '😷', '🤯', '🤫', '🥴', '😴', '🤩', '🥳', '😔', '😩', '🤪', '😇', '🤢', '😈', '👹', '👻', '🤖', '👽', '💀', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', '🐭', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', '🌈'])
44
- for index in noise_indices:
45
- prompt_list[index] = random.choice(noise_chars)
46
- return "".join(prompt_list)
47
-
48
-
49
-
50
- def send_it1(inputs, noise_level, proc1=proc1):
51
- prompt_with_noise = add_random_noise(inputs, noise_level)
52
- while queue.qsize() >= queue_threshold:
53
- time.sleep(2)
54
- queue.put(prompt_with_noise)
55
- output1 = proc1(prompt_with_noise)
56
- return output1
57
-
58
- def send_it2(inputs, noise_level, proc1=proc1):
59
- prompt_with_noise = add_random_noise(inputs, noise_level)
60
- while queue.qsize() >= queue_threshold:
61
- time.sleep(2)
62
- queue.put(prompt_with_noise)
63
- output2 = proc1(prompt_with_noise)
64
- return output2
65
-
66
- #def send_it3(inputs, noise_level, proc1=proc1):
67
- #prompt_with_noise = add_random_noise(inputs, noise_level)
68
- #while queue.qsize() >= queue_threshold:
69
- #time.sleep(2)
70
- #queue.put(prompt_with_noise)
71
- #output3 = proc1(prompt_with_noise)
72
- #return output3
73
-
74
- #def send_it4(inputs, noise_level, proc1=proc1):
75
- #prompt_with_noise = add_random_noise(inputs, noise_level)
76
- #while queue.qsize() >= queue_threshold:
77
- #time.sleep(2)
78
- #queue.put(prompt_with_noise)
79
- #output4 = proc1(prompt_with_noise)
80
- #return output4
81
-
82
-
83
- with gr.Blocks(css='style.css') as demo:
84
- gr.HTML(
85
- """
86
- <div style="text-align: center; max-width: 650px; margin: 0 auto;">
87
- <div>
88
- <h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
89
- OpenART
90
- </h1>
91
- </div>
92
- <p style="margin-bottom: 10px; font-size: 96%">
93
- 差异程度: 用数值调节两张图的差异程度。数值越大,两张图的差异越大,反之越小。
94
- </p>
95
- <p style="margin-bottom: 10px; font-size: 98%">
96
- ❤️ 喜欢的话,就点上面的❤️吧~❤️</a>
97
- </p>
98
- </div>
99
- """
100
- )
101
- with gr.Column(elem_id="col-container"):
102
- with gr.Row(variant="compact"):
103
- input_text = gr.Textbox(
104
- label="Short Prompt",
105
- show_label=False,
106
- max_lines=2,
107
- placeholder="输入你的想象(英文词汇),然后按右边按钮。没灵感?直接按!",
108
- ).style(
109
- container=False,
110
- )
111
- see_prompts = gr.Button("✨ 咒语显现 ✨").style(full_width=False)
112
-
113
-
114
- with gr.Row(variant="compact"):
115
- prompt = gr.Textbox(
116
- label="Enter your prompt",
117
- show_label=False,
118
- max_lines=2,
119
- placeholder="可输入完整描述词,或者用咒语显现按钮生成",
120
- ).style(
121
- container=False,
122
- )
123
- run = gr.Button("✨幻梦显形✨").style(full_width=False)
124
-
125
- with gr.Row():
126
- with gr.Row():
127
- noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="差异程度")
128
- with gr.Row():
129
- with gr.Row():
130
- output1=gr.Image(label="Dreamlike Diffusion 1.0",show_label=False)
131
- output2=gr.Image(label="Dreamlike Diffusion 1.0",show_label=False)
132
-
133
-
134
- see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
135
- run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
136
- run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
137
-
138
-
139
- with gr.Row():
140
- gr.HTML(
141
- """
142
- <div class="footer">
143
-
144
-
145
- <div class="acknowledgments" style="font-size: 115%">
146
- <p>
147
- 安利:一个汉化项目:<a href="https://tiwenti.chat/">TiwenTi.chat</a>,这是一个ChatGPT的中文案例库,按照工具用途和角色扮演用途做了分类,欢迎去看去分享~ </p>
148
- </p>
149
- </div>
150
- """
151
- )
152
-
153
- demo.launch(enable_queue=True, inline=True)
154
- block.queue(concurrency_count=100)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
spaces/Datasculptor/3D-Room-Layout-Estimation_LGT-Net/utils/visibility_polygon.py DELETED
@@ -1,268 +0,0 @@
1
- """
2
- @date: 2021/7/20
3
- @description: reference https://www.redblobgames.com/articles/visibility/
4
- """
5
- import math
6
- import numpy as np
7
- from functools import cmp_to_key as ctk
8
- from PIL import Image
9
-
10
-
11
- class Point:
12
- def __init__(self, x: float, y: float):
13
- self.x = x
14
- self.y = y
15
-
16
-
17
- class EndPoint(Point):
18
- def __init__(self, x: float, y: float, begins_segment: bool = None, segment=None, angle: float = None):
19
- super().__init__(x, y)
20
- self.begins_segment = begins_segment
21
- self.segment = segment
22
- self.angle = angle
23
-
24
-
25
- class Segment:
26
- def __init__(self, x1: float, y1: float, x2: float, y2: float, d: float = None):
27
- self.p1 = EndPoint(x1, y1)
28
- self.p2 = EndPoint(x2, y2)
29
- self.p1.segment = self
30
- self.p2.segment = self
31
- self.d = d
32
-
33
-
34
- def calculate_end_point_angles(light_source: Point, segment: Segment) -> None:
35
- x = light_source.x
36
- y = light_source.y
37
- dx = 0.5 * (segment.p1.x + segment.p2.x) - x
38
- dy = 0.5 * (segment.p1.y + segment.p2.y) - y
39
- segment.d = (dx * dx) + (dy * dy)
40
- segment.p1.angle = math.atan2(segment.p1.y - y, segment.p1.x - x)
41
- segment.p2.angle = math.atan2(segment.p2.y - y, segment.p2.x - x)
42
-
43
-
44
- def set_segment_beginning(segment: Segment) -> None:
45
- d_angle = segment.p2.angle - segment.p1.angle
46
- if d_angle <= -math.pi:
47
- d_angle += 2 * math.pi
48
- if d_angle > math.pi:
49
- d_angle -= 2 * math.pi
50
- segment.p1.begins_segment = d_angle > 0
51
- segment.p2.begins_segment = not segment.p1.begins_segment
52
-
53
-
54
- def endpoint_compare(point_a: EndPoint, point_b: EndPoint):
55
- if point_a.angle > point_b.angle:
56
- return 1
57
- if point_a.angle < point_b.angle:
58
- return -1
59
- if not point_a.begins_segment and point_b.begins_segment:
60
- return 1
61
- if point_a.begins_segment and not point_b.begins_segment:
62
- return -1
63
- return 0
64
-
65
-
66
- def polygon_to_segments(polygon: np.array) -> np.array:
67
- segments = []
68
- polygon = np.concatenate((polygon, [polygon[0]]))
69
- for i in range(len(polygon) - 1):
70
- p1 = polygon[i]
71
- p2 = polygon[i + 1]
72
- segments.append([p1, p2])
73
- segments = np.array(segments)
74
- return segments
75
-
76
-
77
- def segment_in_front_of(segment_a: Segment, segment_b: Segment, relative_point: Point):
78
- def left_of(segment: Segment, point: Point):
79
- cross = (segment.p2.x - segment.p1.x) * (point.y - segment.p1.y) - (segment.p2.y - segment.p1.y) * (
80
- point.x - segment.p1.x)
81
- return cross < 0
82
-
83
- def interpolate(point_a: Point, point_b: Point, f: float):
84
- point = Point(x=point_a.x * (1 - f) + point_b.x * f,
85
- y=point_a.y * (1 - f) + point_b.y * f)
86
- return point
87
-
88
- a1 = left_of(segment_a, interpolate(segment_b.p1, segment_b.p2, 0.01))
89
- a2 = left_of(segment_a, interpolate(segment_b.p2, segment_b.p1, 0.01))
90
- a3 = left_of(segment_a, relative_point)
91
- b1 = left_of(segment_b, interpolate(segment_a.p1, segment_a.p2, 0.01))
92
- b2 = left_of(segment_b, interpolate(segment_a.p2, segment_a.p1, 0.01))
93
- b3 = left_of(segment_b, relative_point)
94
- if b1 == b2 and not (b2 == b3):
95
- return True
96
- if a1 == a2 and a2 == a3:
97
- return True
98
- if a1 == a2 and not (a2 == a3):
99
- return False
100
- if b1 == b2 and b2 == b3:
101
- return False
102
- return False
103
-
104
-
105
- def line_intersection(point1: Point, point2: Point, point3: Point, point4: Point):
106
- a = (point4.y - point3.y) * (point2.x - point1.x) - (point4.x - point3.x) * (point2.y - point1.y)
107
- b = (point4.x - point3.x) * (point1.y - point3.y) - (point4.y - point3.y) * (point1.x - point3.x)
108
- assert a != 0 or a == b, "center on polygon, it not support!"
109
- if a == 0:
110
- s = 1
111
- else:
112
- s = b / a
113
-
114
- return Point(
115
- point1.x + s * (point2.x - point1.x),
116
- point1.y + s * (point2.y - point1.y)
117
- )
118
-
119
-
120
- def get_triangle_points(origin: Point, angle1: float, angle2: float, segment: Segment):
121
- p1 = origin
122
- p2 = Point(origin.x + math.cos(angle1), origin.y + math.sin(angle1))
123
- p3 = Point(0, 0)
124
- p4 = Point(0, 0)
125
-
126
- if segment:
127
- p3.x = segment.p1.x
128
- p3.y = segment.p1.y
129
- p4.x = segment.p2.x
130
- p4.y = segment.p2.y
131
- else:
132
- p3.x = origin.x + math.cos(angle1) * 2000
133
- p3.y = origin.y + math.sin(angle1) * 2000
134
- p4.x = origin.x + math.cos(angle2) * 2000
135
- p4.y = origin.y + math.sin(angle2) * 2000
136
-
137
- # use the endpoint directly when the rays are parallel to segment
138
- if abs(segment.p1.angle - segment.p2.angle) < 1e-6:
139
- return [p4, p3]
140
-
141
- # it's maybe generate error coordinate when the rays are parallel to segment
142
- p_begin = line_intersection(p3, p4, p1, p2)
143
- p2.x = origin.x + math.cos(angle2)
144
- p2.y = origin.y + math.sin(angle2)
145
- p_end = line_intersection(p3, p4, p1, p2)
146
-
147
- return [p_begin, p_end]
148
-
149
-
150
- def calc_visible_polygon(center: np.array, polygon: np.array = None, segments: np.array = None, show: bool = False):
151
- if segments is None and polygon is not None:
152
- segments = polygon_to_segments(polygon)
153
-
154
- origin = Point(x=center[0], y=center[1])
155
- endpoints = []
156
- for s in segments:
157
- p1 = s[0]
158
- p2 = s[1]
159
- segment = Segment(x1=p1[0], y1=p1[1], x2=p2[0], y2=p2[1])
160
- calculate_end_point_angles(origin, segment)
161
- set_segment_beginning(segment)
162
- endpoints.extend([segment.p1, segment.p2])
163
-
164
- open_segments = []
165
- output = []
166
- begin_angle = 0
167
- endpoints = sorted(endpoints, key=ctk(endpoint_compare))
168
-
169
- for pas in range(2):
170
- for endpoint in endpoints:
171
- open_segment = open_segments[0] if len(open_segments) else None
172
- if endpoint.begins_segment:
173
- index = 0
174
- segment = open_segments[index] if index < len(open_segments) else None
175
- while segment and segment_in_front_of(endpoint.segment, segment, origin):
176
- index += 1
177
- segment = open_segments[index] if index < len(open_segments) else None
178
-
179
- if not segment:
180
- open_segments.append(endpoint.segment)
181
- else:
182
- open_segments.insert(index, endpoint.segment)
183
- else:
184
- if endpoint.segment in open_segments:
185
- open_segments.remove(endpoint.segment)
186
-
187
- if open_segment is not (open_segments[0] if len(open_segments) else None):
188
- if pas == 1 and open_segment:
189
- triangle_points = get_triangle_points(origin, begin_angle, endpoint.angle, open_segment)
190
- output.extend(triangle_points)
191
- begin_angle = endpoint.angle
192
-
193
- output_polygon = []
194
- # Remove duplicate
195
- for i, p in enumerate(output):
196
- q = output[(i + 1) % len(output)]
197
- if int(p.x * 10000) == int(q.x * 10000) and int(p.y * 10000) == int(q.y * 10000):
198
- continue
199
- output_polygon.append([p.x, p.y])
200
-
201
- output_polygon.reverse()
202
- output_polygon = np.array(output_polygon)
203
-
204
- if show:
205
- visualization(segments, output_polygon, center)
206
- return output_polygon
207
-
208
-
209
- def visualization(segments: np.array, output_polygon: np.array, center: np.array, side_l=1000):
210
- """
211
- :param segments: original segments
212
- :param output_polygon: result polygon
213
- :param center: visibility center
214
- :param side_l: side length of board
215
- :return:
216
- """
217
- try:
218
- import cv2
219
- import matplotlib.pyplot as plt
220
- except ImportError:
221
- print("visualization need cv2 and matplotlib")
222
- return
223
- offset = np.array([side_l / 2, side_l / 2]) - center
224
- segments = segments + offset
225
- output_polygon = output_polygon + offset
226
- origin = np.array([side_l / 2, side_l / 2])
227
-
228
- # +0.5 as board
229
- scale = side_l / 2.5 / np.abs(segments - origin).max()
230
- board = np.zeros((side_l, side_l))
231
- for segment in segments:
232
- segment = (segment - origin) * scale + origin
233
- segment = segment.astype(np.int)
234
- cv2.line(board, tuple(segment[0]), tuple(segment[1]), 0.5, thickness=3)
235
- board = cv2.drawMarker(board, tuple(origin.astype(np.int)), 1, thickness=3)
236
-
237
- output_polygon = (output_polygon - origin) * scale + origin
238
- board = cv2.drawContours(board, [output_polygon.astype(np.int)], 0, 1, 3)
239
- board = cv2.drawMarker(board, tuple(origin.astype(np.int)), 1, thickness=3)
240
- plt.axis('off')
241
- plt.imshow(board)
242
- plt.show()
243
-
244
-
245
- if __name__ == '__main__':
246
- import numpy as np
247
-
248
- from dataset.mp3d_dataset import MP3DDataset
249
- from utils.boundary import depth2boundaries
250
- from utils.conversion import uv2xyz, depth2xyz
251
- from visualization.boundary import draw_boundaries
252
- from visualization.floorplan import draw_floorplan, draw_iou_floorplan
253
-
254
- mp3d_dataset = MP3DDataset(root_dir='../src/dataset/mp3d', mode='train',
255
- split_list=[['e9zR4mvMWw7', '2224be23a70a475ea6daa55d4c90a91b']])
256
- gt = mp3d_dataset.__getitem__(0)
257
- gt['corners'] = gt['corners'][gt['corners'][..., 0] + gt['corners'][..., 1] != 0] # Take effective corners
258
-
259
- img = draw_floorplan(depth2xyz(gt['depth'])[:, ::2], fill_color=[1, 1, 1, 0],
260
- show=True, scale=1, marker_color=[0, 0, 1, 1], side_l=1024)
261
- # img = draw_iou_floorplan(gt_xz=uv2xyz(gt['corners'])[..., ::2],
262
- # dt_xz=calc_visible_polygon(np.array([0, 0]), uv2xyz(gt['corners'])[..., ::2]),
263
- # dt_board_color=[0, 0, 1, 0],
264
- # gt_board_color=[0, 0, 1, 0],
265
- # show=True, side_l=1024)
266
-
267
- result = Image.fromarray((img[250: -100, 100:-20] * 255).astype(np.uint8))
268
- result.save('../src/fig/sample3.png')